# Creating a New API Key

### <mark style="color:green;">`POST`</mark> `/auth/createkey`

Create/generate a new API key for your Mobivate account.&#x20;

{% tabs %}
{% tab title="Curl" %}

```hsts
curl -X POST \
"https://api.mobivatebulksms.com/auth/createkey" \
-H 'Content-Type: application/json' \
-d '{ "username": "first.last@email.com", "password": "your-pass"}'
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

headers = {
    'Content-Type': 'application/json',
}

json_data = {
    'username': 'first.last@email.com',
    'password': 'your-pass',
}

response = requests.post('https://api.mobivatebulksms.com/auth/createkey', headers=headers, json=json_data)

# Note: json_data will not be serialized by requests
# exactly as it was in the original request.
#data = '{ "username": "first.last@email.com", "password": "your-pass"}'
#response = requests.post('https://api.mobivatebulksms.com/auth/createkey', headers=headers, data=data)
```

{% endtab %}
{% endtabs %}

**Headers**

| Name          | Value              |
| ------------- | ------------------ |
| Content-Type  | `application/json` |
| Authorization | `No Auth`          |

**Body**

<table><thead><tr><th>Name</th><th width="131">Type</th><th width="111">Required?</th><th>Description</th></tr></thead><tbody><tr><td>username</td><td>string</td><td>Yes</td><td>Your username used to login.</td></tr><tr><td>password</td><td>string</td><td>Yes</td><td>Your password used to login.</td></tr></tbody></table>

**Response**

We use conventional HTTP response codes to indicate the success or failure of an API request. In general:

**2xx** indicate success\
**4xx** indicate an error that failed given the information provided (e.g., a required parameter was omitted)\
**5xx** errors indicate an error with ours servers (these are rare).

{% tabs %}
{% tab title="200" %}

```json
{
   "apiKey":"abcd1234-9922-abcd-1234-abcd1234abcd"
}
```

{% endtab %}

{% tab title="401" %}

```json
{
   "code":401,
   "message":"Invalid Credentials"
}
```

{% endtab %}
{% endtabs %}

Upon a successful send request, our server will respond with a 200 (success) HTTP response code, and you will be provided with an API Key. The **API Key** will be used in subsequent calls to the API.

{% hint style="warning" %}
**Please note**: A successful call to this endpoint will revoke your existing API Key!&#x20;
{% endhint %}

To see a full list of our **Response codes**, please [click here](https://wiki.mobivatebulksms.com/overview/introduction/understanding-response-codes).
