2.5 KiB
2.5 KiB
title |
---|
Read an API key |
Reads an existing API key. Note that the API secret can only be retrieved at the moment the API key is created.
Access control
- Permission level
4
or higher is required to read an API key
Endpoints
Reading an API key is possible via these endpoints:
Method | Path | Authentication |
---|---|---|
/apikeys/:id/jwt |
JSON Web Token | |
/apikeys/:id/key |
API Key & Secret |
Request URL
The URL should contain the ID of the API key you wish to remove.
It replaces the :id
placeholder in the endpoints listed above.
Response status codes
Possible status codes for these endpoints are:
Status code | Description |
---|---|
success | |
the request was malformed | |
the request lacks authentication | |
authentication failed | |
API key not found | |
server error |
Response body
Value | Type | Description |
---|---|---|
result |
string |
success on success, and error on error |
error |
string |
Will give info on the nature of the error. Only set if an error occurred. |
apikey.key |
string |
The API key |
apikey.level |
number |
The privilege level of the API key |
apikey.expiresAt |
string |
A string representation of the moment the API key expires |
apikey.name |
string |
The name of the API key |
apikey.userId |
number |
The ID of the user who created the API key |
Example request
const keyInfo = await axios.get(
'https://backend.freesewing.org/apikeys/7ea12968-7758-40b6-8c73-75cc99be762b/jwt',
{
headers: {
Authorization: `Bearer ${token}`
}
}
)
Example response
{
"result": "success",
"apikey": {
"key": "7ea12968-7758-40b6-8c73-75cc99be762b",
"level": 3,
"expiresAt": "2022-11-06T15:57:30.190Z",
"name": "My first API key",
"userId": 61
}
}