Get an API key

This endpoint retrieves the details of a specific API key, identified by its unique API Key ID ({id}). It provides metadata and configuration details for the API key.


Request

Endpoint

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

Required Keys

ParameterDescription
{id}The unique identifier of the API key to retrieve.
bearer tokenThe authentication token returned by /oauth2/token.

Body Parameters

This endpoint does not require body parameters.


Response

Field Definitions

Field NameTypeDescription
statusStringStatus of the API request (SUCCESS, FAILED).
successBooleanIndicates if the API key retrieval was successful.
IdStringThe unique identifier of the API key.
nameStringThe name or description of the API key.
typeString (Enum)The type of the API key (secret , public or tokenization).
scopesArray of StringsThe list of scopes defining the access level of the API key.
createdOnStringTimestamp of when the API key was created (ISO 8601 format).
lastUsedStringTimestamp of when the API key was last used (ISO 8601 format).
lastFourStringThe last four characters of the API key, for identification.
errorsArray of StringsAny errors encountered during the API key retrieval process.

❗️

Notes

  • The full secret API key value is not returned for security reasons. Use the last four characters (lastFour) for identification.
  • Ensure secure handling of API key details and verify scopes for proper integration management.

Payload Examples

Request

cURL Request Example

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

Response

JSON Example for a Successful Retrieval

{
   "status": "SUCCESS",
   "success": true,
   "id": "key_abc123",
   "name": "My API Key",
   "type": "secret",
   "scopes": ["customers:read", "charges:read"],
   "createdOn": "2024-11-01T10:00:00Z",
   "lastUsed": "2024-11-15T12:00:00Z",
   "lastFour": "7dc0",
   "errors": []
}

JSON Example for a Failed Retrieval

{
   "status": "FAILED",
   "success": false,
   "id": null,
   "name": null,
   "type": null,
   "scopes": null,
   "createdOn": null,
   "lastUsed": null,
   "lastFour": null,
   "errors": [
       "API key not found.",
       "Invalid API key ID."
   ]
}

Example for Handling Errors

  • If the API Key ID is invalid, the API will return an error.
  • If the bearer token is unauthorized, the API will respond with an Unauthorized error.
HTTP/1.1 404 Not Found
Content-Type: application/json

{
  "errors": [
    "API key not found."
  ]
}
HTTP/1.1 401 Unauthorized
Content-Type: application/json

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