Unicat API Reference

Up - API Reference - Home


/api/p/<project gid>/apikeys/create

Requires JWT.

Creates an API key for the project. An API key can never be used for other projects.

Only the owner of the project can create API keys.

With this key you can programmatically perform any action a logged in user can. Don't give out these keys lightly!

An API key is always a member of the project, so cannot do actions an owner can do. An API key has an associated user, this is the API user. This user's gid is used to link API users to projects, and API users and regular users are both returned in the list of members for a project.

The result of the apikeys/create call is the newly created API user. If you want to get the actual API key, use /api/p/<project gid>/apikeys/get to subsequently fetch it.

If you give the API key to someone else, please do so securely.

Request

POST /api/p/<project gid>/apikeys/create
Authorization: Bearer <JWT>

{
    "name": "Import/export data API key",
}

name provides a description of what the API key should be used for.

Success response

Authorization: <JWT>

{
    "success": true,
    "result": {
        "user": "b76f701d-3d34-4f39-8eeb-fafe294ab01e",
    },
    "data": {
        "cc.users": {
            "b76f701d-3d34-4f39-8eeb-fafe294ab01e": {
                "gid": "b76f701d-3d34-4f39-8eeb-fafe294ab01e",
                "name": "Import/export data API key",
                "avatar": null,
                "username": null
            },
        },
        "cc.projects_members": [
            {
                "project_gid": "<project gid>",
                "user_gid": "b76f701d-3d34-4f39-8eeb-fafe294ab01e",
                "status": "active",
                "roles": [
                    "api"
                ],
                "options": {
                    "rate_limit_per_second": null
                }
            }
        ]
    }
}

result

user is the new API user's gid.

data

cc.users is a dictionary with an entry for the API user.
cc.projects_members is a list with metadata for the new API user for this project.

Error responses

401 Unauthorized - missing or expired JWT
403 Forbidden - not the owner of this project