---
title: Set up to use IBM Quantum Platform with REST API
description: Setup instructions to use the REST API to submit IBM Quantum Compute Service jobs
source: https://eu-de.quantum.cloud.ibm.com/docs/en/guides/cloud-setup-rest-api
---

# Set up to use IBM Quantum Platform with REST API

You can access quantum processors with REST APIs, enabling you to work with QPUs using any programming language or framework.

### 1. Get access

1. If you do not already have a user account, get one at the [IBM Quantum login page](/login).
2. Create an API key (also called a token) on the [dashboard](). Note that the same API key can be used for either region.
3. Generate an IBM Cloud Identity and Access Management (IAM) bearer token. This is a short-lived token  used to authenticate requests to the REST API. To generate one, call the [IAM Identity Services API](https://cloud.ibm.com/apidocs/iam-identity-token-api#create-api-key) as shown in the following sample request:

### Curl

```bash
curl -X POST 'https://iam.cloud.ibm.com/identity/token' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d 'grant_type=urn:ibm:params:oauth:grant-type:apikey&apikey=MY_APIKEY'
```

Expected Response

```text
{
   "access_token": "eyJhbGciOiJIUz......sgrKIi8hdFs",
   "refresh_token": "SPrXw5tBE3......KBQ+luWQVY=",
   "token_type": "Bearer",
   "expires_in": 3600,
   "expiration": 1473188353
}
```

### Python

```python
# Use 'service' to invoke operations.
import requests
import json

url = 'https://iam.cloud.ibm.com/identity/token'
api_key = 'MY_APIKEY'
headers = {
 'Content-Type': 'application/x-www-form-urlencoded',
}
data = f'grant_type=urn:ibm:params:oauth:grant-type:apikey&apikey={api_key}'
response = requests.post(url, headers=headers, data=data)

# Bearer token to authorize requests to the REST API
bearer_token = response.json()['access_token']
```

### 2. Choose an authentication method

Choose the appropriate authentication method, depending on your working environment:

- [Create an environment variable for your API key (trusted Python environments)](#environment_variable)
- [Use your API key directly (untrusted environment)](/docs/guides/cloud-setup-untrusted#rest-untrusted)

#### Create an environment variable (trusted environment)

1. To set the IQP\_API\_TOKEN environment variable in your system, you can add the following line to your shell profile (for example, .bashrc or .zshrc) or by setting it directly in your terminal:

   ```shell
   export IQP_API_TOKEN=<your-API_KEY> 
   # Use the 44-character API_KEY you created and saved 
   # from the IBM Quantum Platform Home dashboard
   ```

   When you invoke the environment variable in your code, include `import os`, as in this example:

   ```python
   import os
   api_token = os.environ['IQP_API_TOKEN']
   ```

   Note that when creating an environment variable, your API key is still stored locally in plain text, and should be safeguarded.

2. Authenticate requests to the REST API by including the CRN and bearer token to the request's headers.

```bash
curl -X 'GET' \
   'https://quantum.cloud.ibm.com/api/v1/usage' \
   '-H accept: application/json' \
   '-H authorization: Bearer <BEARER_TOKEN>' \
   '-H Service-CRN: <INSTANCE_CRN>'
```

### 3. Optional: Configure your firewall

If necessary, use [this information](/docs/guides/quickstart-steps-org#firewall) to enable access to the IBM Quantum API endpoints.

## Next steps

> **Recommendations**
>
> - [Overview of available plans](/docs/guides/plans-overview).
> - [Configure the Qiskit SDK locally](/docs/guides/configure-qiskit-local).
> - Follow the steps in the [Run your first circuit on hardware](/docs/guides/hello-world) guide to write and run a quantum program.
> - Try a [tutorial](/docs/tutorials).
