# API Key - Create

Create an API Key for a merchant.

## Request

POST <https://sandbox.hyperswitch.io/api\\_keys/{merchant\\_id}>

Headers:

* Content-Type: application/json
* api-key: (Admin API key required)

Path parameters:

* merchant\_id (string, required) — The unique identifier for the merchant account.

### Example (cURL)

{% code title="create-api-key.sh" %}

```bash
curl --request POST \
  --url https://sandbox.hyperswitch.io/api_keys/{merchant_id} \
  --header 'Content-Type: application/json' \
  --header 'api-key: <api-key>' \
  --data '
{
  "name": "Sandbox integration key",
  "expiration": "never",
  "description": "Key used by our developers to integrate with the sandbox environment"
}
'
```

{% endcode %}

## Authorization

{% hint style="info" %}
Header: `api-key` (string, required)

Admin API keys allow privileged actions such as creating a merchant account and Merchant Connector account.
{% endhint %}

## Body

Content-Type: application/json

The request body for creating an API Key:

* name (string, required) — A unique name for the API Key. Maximum length: 64.\
  Example: `"Sandbox integration key"`
* expiration (enum|string, required) — Available options: `never`
* description (string|null, optional) — Description for context. Maximum length: 256.\
  Example: `"Key used by our developers to integrate with the sandbox environment"`

## Response

Status: 200 — application/json\
API Key created. Response body:

{% code title="response.json" %}

```json
{
  "key_id": "5hEEqkgJUyuxgSKGArHA4mWSnX",
  "merchant_id": "y3oqhf46pyzuxjbcn2giaqnb44",
  "name": "Sandbox integration key",
  "api_key": "<string>",
  "created": "2022-09-10T10:11:12Z",
  "expiration": "never",
  "description": "Key used by our developers to integrate with the sandbox environment"
}
```

{% endcode %}

Response fields:

* key\_id (string, required) — Identifier for the API Key. Max length: 64. Example: `"5hEEqkgJUyuxgSKGArHA4mWSnX"`
* merchant\_id (string, required) — Identifier for the Merchant Account. Max length: 64. Example: `"y3oqhf46pyzuxjbcn2giaqnb44"`
* name (string, required) — The unique name for the API Key. Max length: 64.
* api\_key (string, required) — The plaintext API Key used for server-side API access. Store securely; you will not be able to see it again. Max length: 128.
* created (string, required) — Creation time. Example: `"2022-09-10T10:11:12Z"`
* expiration (enum|string, required) — Available options: `never`
* description (string|null) — Description for context. Max length: 256.

## Related

* Platform - Create: <https://api-reference.hyperswitch.io/v1/platform/platform--create>
* API Key - Retrieve: <https://api-reference.hyperswitch.io/v1/api-key/api-key--retrieve>

Suggest edits: <https://github.com/juspay/hyperswitch/edit/main/api-reference/v1/api-key/api-key--create.mdx\\>
Raise issue: <https://github.com/juspay/hyperswitch/issues/new?title=Issue%20on%20docs\\&body=Path:%20/v1/api-key/api-key--create>

<details>

<summary>Was this page helpful?</summary>

Yes / No

</details>

Assistant: Responses are generated using AI and may contain mistakes.
