Create an API key
FlexFactor allows you to create API keys to authenticate and interact with FlexFactor API endpoints.
Request
Endpoints
| Environment | HTTP Method | Endpoint |
|---|---|---|
| Sandbox testing | POST | https://api-sandbox.flexfactor.io/v1/merchants/{mid}/api-keys |
| Production environment | POST | https://api.flexfactor.io/v1/merchants/{mid}/api-keys |
Required Keys
| Parameter | Description |
|---|---|
{mid} | Path parameter. The unique identifier (GUID) of the merchant you want to create credentials for. The merchant must belong to your partner account. |
bearer token | The authentication token returned by /oauth2/token for your partner credentials. The token needs the api-client.write or api-client.manage scope. |
Body
| Field Name | Type | Required | Description |
|---|---|---|---|
name | String | required | A name for the API key. 1 to 255 characters. |
description | String | required | A description for the API key. Up to 500 characters. |
overwriteExistingKey | Boolean | recommended | What to do when the merchant already has API credentials:false: no new key is created. The response returns the merchant's existing credentials.true: the merchant's current API client is replaced with a new one, and the response returns new credentials. Treat the previous credentials as no longer usable. |
SendoverwriteExistingKeyon every requestSend
trueorfalseexplicitly so the outcome for a merchant that already has credentials is the one you intend. When the merchant has no credentials yet, both values create a new key.
Response
A successful request returns 201 Created with the credentials.
Field Definitions
| Field Name | Type | Description |
|---|---|---|
name | String | The name of the merchant's API client. |
uniqueName | String | The unique name of the merchant's API client. |
description | String | The description of the merchant's API client. |
clientId | String | Unique identifier (GUID) of the merchant's API client. |
appKey | String | The merchant's appKey. Send it to /oauth2/token to authenticate. |
appSecret | String | The merchant's appSecret. Send it to /oauth2/token to authenticate. |
Security forappSecretStore the
appSecretsecurely and share it only with the merchant it belongs to. Anyone holding theappKeyandappSecretcan authenticate as that merchant.
HTTP status codes
| Situation | HTTP | Body |
|---|---|---|
| Key created, or existing credentials returned | 201 | The credentials object |
| A required field is missing, or a field fails validation | 400 | Validation problem details — see Error Handling |
| The bearer token is not a partner token | 400 | The message Partner ID not found in token claims |
| Missing, invalid, or expired bearer token | 401 | — |
| The merchant does not belong to your partner account | 401 | The message Access denied: Merchant does not belong to your partner account |
The token does not carry the api-client.write or api-client.manage scope | 403 | — |
{mid} is not a GUID | 404 | — |
| The merchant lookup failed, or an unexpected error occurred | 500 | An error message |
Payload Examples
Request
cURL Request Example
curl --request POST \
--url https://api-sandbox.flexfactor.io/v1/merchants/{mid}/api-keys \
--header 'Authorization: Bearer {the token returned by /oauth2}' \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '{
"name": "My API Key",
"description": "Key for the merchant integration",
"overwriteExistingKey": false
}'
Response
JSON Example for a Successful Creation
{
"name": "My API Key",
"uniqueName": "My API Key",
"description": "Key for the merchant integration",
"clientId": "{{$guid}}",
"appKey": "{appKey}",
"appSecret": "{appSecret}"
}
Example for Handling Errors
- Missing Fields: If a required field is missing, the API returns a 400 error with validation problem details.
- Invalid Credentials: If the bearer token is missing, invalid, or expired, the API returns a 401 error with an empty body.
- Merchant not in your account: If the merchant does not belong to your partner account, the API returns a 401 error with a message.
HTTP/1.1 400 Bad Request
Content-Type: application/problem+json
{
"type": "https://tools.ietf.org/html/rfc9110#section-15.5.1",
"title": "One or more validation errors occurred.",
"status": 400,
"errors": {
"Name": [
"The Name field is required."
]
}
}HTTP/1.1 401 Unauthorized
Access denied: Merchant does not belong to your partner accountUpdated about 4 hours ago
Did this page help you?

