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

Endpoints

Reading an API key is possible via these endpoints:

MethodPathAuthentication
GET
/apikeys/:id/jwtJSON Web Token
GET
/apikeys/:id/keyAPI 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 codeDescription
200
success
400
the request was malformed
401
the request lacks authentication
403
authentication failed
404
API key not found
500
server error
Note

If the status code is not

200
the error property in the response body should indicate the nature of the problem.

Response body

ValueTypeDescription
resultstringsuccess on success, and error on error
errorstringWill give info on the nature of the error. Only set if an error occurred.
apikey.keystringThe API key
apikey.levelnumberThe privilege level of the API key
apikey.expiresAtstringA string representation of the moment the API key expires
apikey.namestringThe name of the API key
apikey.userIdnumberThe ID of the user who created the API key

Example request

Javascript
const keyInfo = await axios.get(
  'https://backend.freesewing.org/apikeys/7ea12968-7758-40b6-8c73-75cc99be762b/jwt',
  {
    headers: {
      Authorization: `Bearer ${token}`
    }
  }
)

Example response

JSON
200
{
  "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
  }
}