Create an API key

FlexFactor allows you to create API keys to authenticate and interact with FlexFactor API endpoints.


Request

Endpoints

EnvironmentHTTP MethodEndpoint
Sandbox testingPOSThttps://api-sandbox.flexfactor.io/v1/merchants/{mid}/api-keys
Production environmentPOSThttps://api.flexfactor.io/v1/merchants/{mid}/api-keys

Required Keys

ParameterDescription
{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 tokenThe authentication token returned by /oauth2/token for your partner credentials. The token needs the api-client.write or api-client.manage scope.

Body

Field NameTypeRequiredDescription
nameStringrequiredA name for the API key. 1 to 255 characters.
descriptionStringrequiredA description for the API key. Up to 500 characters.
overwriteExistingKeyBooleanrecommendedWhat 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.
📌

Send overwriteExistingKey on every request

Send true or false explicitly 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 NameTypeDescription
nameStringThe name of the merchant's API client.
uniqueNameStringThe unique name of the merchant's API client.
descriptionStringThe description of the merchant's API client.
clientIdStringUnique identifier (GUID) of the merchant's API client.
appKeyStringThe merchant's appKey. Send it to /oauth2/token to authenticate.
appSecretStringThe merchant's appSecret. Send it to /oauth2/token to authenticate.


❗️

Security for appSecret

Store the appSecret securely and share it only with the merchant it belongs to. Anyone holding the appKey and appSecret can authenticate as that merchant.


HTTP status codes

SituationHTTPBody
Key created, or existing credentials returned201The credentials object
A required field is missing, or a field fails validation400Validation problem details — see Error Handling
The bearer token is not a partner token400The message Partner ID not found in token claims
Missing, invalid, or expired bearer token401—
The merchant does not belong to your partner account401The message Access denied: Merchant does not belong to your partner account
The token does not carry the api-client.write or api-client.manage scope403—
{mid} is not a GUID404—
The merchant lookup failed, or an unexpected error occurred500An 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 account

Did this page help you?