# Creates a merchant API key

<span class="api-endpoint">POST {{<a href="#urlbases">baseURL</a>}}/pay-api/v1/merchants/tokens</span>
This endpoint creates an API key for a merchant managed by their partner account.
Provide the Merchant ID and a API key name to generate a client Id and client secret for the merchant.
Use the returned credentials to authenticate as the merchant for API operations.
This endpoint requires the API token to be from a partner API key.
API tokens generated from a merchant key are not accepted.

Endpoint: POST /pay-api/v1/merchants/tokens
Version: V1
Security: Bearer

## Request fields (application/json):

  - `merchantId` (string, required)
    Specifies the identifier of the merchant.

Example: 46063d32-10fa-44cb-b118-20ddd085ce3f
    Example: 46063d32-10fa-44cb-b118-20ddd085ce3f

  - `tokenName` (string, required)
    A free-formed descriptive name for the API key.

Example: Peppared Street Cafe's API Key
    Example: Peppared Street Cafe's API Key

## Response 200 fields (application/json):

  - `clientId` (string)
    Identifies the clientId associated with the API key.
See `clientSecret` for the client secret.
Example: 3b87fab4-5be4-44d3-9070-5f6ec1dfcbf5
    Example: 3b87fab4-5be4-44d3-9070-5f6ec1dfcbf5

  - `clientSecret` (string)
    Identifies the client secret associated with the API key.
This value is only shown once at the time of creation.
Be sure to store it securely, as it cannot be retrieved again later.
See `clientId` for the client identifier.

## Response 400 fields (application/json):

  - `details` (string)
    Indicates details about the error.

Example: Validation failed: -- Email: 'Email' is not a valid email address. Severity: Error
    Example: Validation failed: -- Email: 'Email' is not a valid email address. Severity: Error

  - `statusCode` (integer)
    Specifies the HTTP response status code.
This is the HTTP status code returned by the attempted delivery.
The following is a list of HTTP response status codes that include but are not limited to:
| HTTP Status | Meaning |
|  --- | --- |
| 200 | Delivery succeeded |
| 400 | Bad request |
| 401 | Unauthorized |
| 404 | Endpoint not found |
| 429 | Rate limited |

Example: 401
    Example: 401

  - `source` (string)
    Indicates the source of the error.
Example: <Service>
    Example: <Service>

  - `exceptionType` (string)
    Indicates the error's exception type.

Example: FluentValidation.ValidationException
    Example: FluentValidation.ValidationException

  - `correlationId` (string)
    Indicates the correlation identifier.

Example: aa6cfcd0-0295-4a4c-b074-8c901f114fef
    Example: aa6cfcd0-0295-4a4c-b074-8c901f114fef

  - `entityId` (string)
    Indicates the entity identifier.
Example:
null

  - `errorCode` (string)
    Indicates the error code.
Example:
null

## Response 404 fields (application/json):

  - `details` (string)

  - `statusCode` (integer)
    Specifies the HTTP response status code.
This is the HTTP status code returned by the attempted delivery.
The following is a list of HTTP response status codes that include but are not limited to:
| HTTP Status | Meaning |
|  --- | --- |
| 200 | Delivery succeeded |
| 400 | Bad request |
| 401 | Unauthorized |
| 404 | Endpoint not found |
| 429 | Rate limited |

Example: 401
    Example: 401

  - `source` (string)

  - `exceptionType` (string)

  - `correlationId` (string)

  - `entityId` (string)

  - `errorCode` (string)

## Response 500 fields (application/json):

  - `details` (string)

  - `statusCode` (integer)
    Specifies the HTTP response status code.
This is the HTTP status code returned by the attempted delivery.
The following is a list of HTTP response status codes that include but are not limited to:
| HTTP Status | Meaning |
|  --- | --- |
| 200 | Delivery succeeded |
| 400 | Bad request |
| 401 | Unauthorized |
| 404 | Endpoint not found |
| 429 | Rate limited |

Example: 401
    Example: 401

  - `source` (string)

  - `exceptionType` (string)

  - `correlationId` (string)

  - `entityId` (string)

  - `errorCode` (string)

