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
| Environment | HTTP Method | Endpoint | 
|---|---|---|
| Sandbox testing | GET | https://api-sandbox.flex-charge.com/v1/api-keys/{id} | 
| Production environment | GET | https://api.flex-charge.com/v1/api-keys/{id} | 
Required Keys
| Parameter | Description | 
|---|---|
| {id} | The unique identifier of the API key to retrieve. | 
| bearer token | The authentication token returned by /oauth2/token. | 
Body Parameters
This endpoint does not require body parameters.
Response
Field Definitions
| Field Name | Type | Description | 
|---|---|---|
| status | String | Status of the API request ( SUCCESS,FAILED). | 
| success | Boolean | Indicates if the API key retrieval was successful. | 
| Id | String | The unique identifier of the API key. | 
| name | String | The name or description of the API key. | 
| type | String (Enum) | The type of the API key ( secret,publicortokenization). | 
| scopes | Array of Strings | The list of scopes defining the access level of the API key. | 
| createdOn | String | Timestamp of when the API key was created (ISO 8601 format). | 
| lastUsed | String | Timestamp of when the API key was last used (ISO 8601 format). | 
| lastFour | String | The last four characters of the API key, for identification. | 
| errors | Array of Strings | Any errors encountered during the API key retrieval process. | 
Notes
- The full
secretAPI 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."
  ]
}Updated 5 months ago
