Skip to main content

Create a new User API key

Jetmir Abdija avatar
Written by Jetmir Abdija
Updated over a month ago

The system allows the creation of API keys for individual users in BlueDolphin, along with an expiration date. This enables secure access and interaction with the system APIs, restricted to their designated roles and permissions. The Administrators role in BlueDolphin enables the user to generate personalized API keys for other users. Here we provide the steps for creating a new API key in BlueDolphin.

HTTP responses

HTTP response status code

Interpretation

201 Created

Key created successfully

400 Bad Request

One or more parameters are missing or incorrect.

The response body returns a specific error:

  • Missing or empty name value

  • Name length is incorrect

  • User ID is missing or incorrect

  • Missing or invalid expiration date

  • Expiration date is in the past

401 Unauthorized

Invalid or missing API key secret and/or tenant

To create a new API key, make a POST request to the /user-api-keys endpoint specifying:

  • Resource/endpoint destination URL

  • The header for your API request

  • The request body, which must include:

Parameter

Required

Type

Description

name

βœ“

string

The name of the key to be created. Duplicate names are allowed. The name length must be between three and 255 characters.

user_id

βœ“

string

Unique identifier for the existing user that the key needs to be based on. This key can be found in BlueDolphin in the Admin section under Users. The user_id field is the last parameter in the URL, for example: https://bluedolphin.app/<tenant>/admin/users/<user_id>

expiration_date

βœ“

string

The expiration date of the key that must not be in the past. The date must be in ISO-8601 format ('YYYY-MM-DD').

Here is a sample API request which shows how to create a new API key, Refer Create User Key Management for more information.

curl -L 'https://public-api.eu.bluedolphin.app/v1/user-api-keys' \
-H 'x-api-key: YOURAPIKEYSECRET' \
-H 'tenant: yourtenantname' \
-H 'Content-Type: application/json' \
-d '{
    "name": "BrandNewKey",
    "user_id": "643e9020d97c6a7e28665255",
    "expiration_date": "2024-12-12"
}'

Response properties

Property

Type

Description

id

string

Unique identifier for the API key

key

string

Unhashed API key

A successful call returns a response with a 201 OK HTTP status code and the following body

{
    "id": "63c57b3882345012d9e7a157",
    "key": "65662264-dd0e-46eb-9b11-ab2fb426bbc2"
}

A new key 65662264-dd0e-46eb-9b11-ab2fb426bbc2 expiring on 2024-12-12 has now been created.

Please be aware that the new key cannot be retrieved after this point. You will need to store this key yourself for further usage and reference.

Did this answer your question?