List of API keys

This endpoint retrieves a list of all API keys associated with the authenticated FlexFactor account and a specified mid.



Request

Endpoints

EnvironmentHTTP MethodEndpoint
Sandbox testingGEThttps://api-sandbox.flex-charge.com/v1/api-keys/{mid}
Production environmentGEThttps://api.flex-charge.com/v1/api-keys/{mid}

Required Keys

ParameterDescription
bearer tokenThe authentication token returned by /oauth2/token.
midThe unique FlexFactor identifier of the account associated with the API keys.

Request Body

This endpoint doesn't require body parameters.




Response

Field Definitions

Field NameTypeDescription
nameStringThe name or description of the API Key, as specified during creation.
typeString (Enum)The type of the API Key (secret or public).
created_atString (DateTime)The timestamp of when the API Key was created.
last_usedString (DateTime)The timestamp of the last usage of the API Key.
last_fourStringThe last four characters of the API Key, for easy identification.

Important Notes

  • Key Security: For security reasons, the full key value for secret keys is not returned in this endpoint. To retrieve the full value, use the API key creation endpoint when generating a new key.
  • Key Identification: Use last_four and name to identify keys within your system.

Payload Examples

Request

cURL Request Example

curl --request GET \
     --url https://api-sandbox.flexfactor.com/v1/api-keys/{mid} \
     --header 'Authorization: bearer {the token returned by /oauth2}' \
     --header 'accept: application/json' \
     

Response

JSON Example for a Successful Retrieval

{
   "keys": [
       {
           "name": "My API Key",
           "type": "secret",
           "created_at": "2024-11-16T12:00:00Z",
           "last_used": "2024-11-18T10:00:00Z",
           "last_four": "7dc0"
       },
       {
           "name": "Frontend Key",
           "type": "publishable",
           "created_at": "2024-11-10T08:30:00Z",
           "last_used": null,
           "last_four": "3abc"
       }
   ]
}

JSON Example for No API Keys Found

{
   "keys": []
}

Example for Handling Errors

Invalid Credentials: If the bearer token is invalid or expired, the API will return a 401 error.

HTTP/1.1 401 Unauthorized
Content-Type: application/json

{
  "errors": [
    "Authentication failed. Invalid bearer token."
  ]
}

Internal Server Error: If the system encounters an error processing the request.

HTTP/1.1 500 Internal Server Error
Content-Type: application/json

{
  "errors": [
    "An unexpected error occurred. Please try again later."
  ]
}