Unicat API Reference

Up - API Reference - Home


/api/p/<project gid>/auth

Provide your api_key, get a JWT and initial user and projects data, and initial data for the current project. The JWT is used in subsequent requests that require authorization. The initial data is a convenience that you can also get from the /api/p/<project gid>/init call.

Any subsequent request that uses the JWT can auto-refresh it if it's not expired. If that happens, you'll get a new Authorization header in the response with the renewed JWT, and you should use that one from then on.

Making this call to the project api will give you specific initial data for that project and its members - but only if the api_key user is actually a member of the project.

An api_key user cannot own projects.

Request

POST /api/p/<project gid>/auth

{
    "api_key": "<your-api_key-here>"
}

Success response

Authorization: <JWT>

{
    "success": true,
    "result": {
        "user": "<user gid>",
        "user_projects": {
            "<project gid>": [
                "owner"
            ],
            
        },
        "project": "<project gid>",
        "project_members": ["<user gid>", "<member user gid>", ],
        "last_backed_up": 1612184925.9805226,
        "cc.version": "2022.01.001",
        "cc.cursor": 4132,
        "cursor": 7864,
    },
    "data": {
        "cc.users": {
            "<user gid>": {
                "gid": "<user gid>",
                "username": "user-name",
                "email": "<user email>",
                "name": "User Name",
                "avatar": "1ad71cbd-9b97-4ea7-94ef-bcdd86c6467c.jpg",
                "status": "active",
                "options": {
                    "language": "en",
                    "timezone": "Europe/Amsterdam"
                }
            },
            "<member user gid>": {
                "gid": "<member user gid>",
                "username": "member-name",
                "name": "Member Name",
                "avatar": "f2e64fe0-9ffa-4d9a-8750-d561d6542453.png",
                "status": "active"
            },
            
        },
        "cc.projects": {
            "<project gid>": {
                "gid": "<project gid>",
                "name": "Project Name",
                "icon": "<project gid>.jpg",
                "owner": "<user gid>",
                "status": "active",
                
            },
            
        },
        "cc.projects_members": [
            {
                "project_gid": "<project gid>",
                "user_gid": "<user gid>",
                "status": "active",
                "roles": [
                    "owner"
                ],
                "options": {
                    "notifications": {
                        "email": "<user email>",
                        "events": [
                            "all"
                        ],
                        "frequency": "immediate"
                    },
                    "rate_limit_per_second": null
                }
            },
            {
                "project_gid": "<project gid>",
                "user_gid": "<member user gid>",
                "status": "active",
                "roles": [
                    "member"
                ]
            },
            
        ],
        "cc.languages": {
            "da": "Danish",
            "nl": "Dutch",
            
        },
        "definitions": {},
        "classes": {},
        "fields": {},
        "layouts": {},
        "queries": {},
    }
}

The JWT you need is in the Authorization header.

result

user is the user gid if the auth attempt is successful.
user_projects is a list of zero projects that are owned by this api_key user.
project is the project gid if the user is a member of the project. If not, this value will be null, but the login is still valid.
project_members is a list of project members gids (these are user gids).
last_backed_up is a server-side timestamp for the last backup of the database, or null if it was never backed up.
cc.version is the current version.
cc.cursor a sync cursor, to keep cc-data in sync.
cursor a sync cursor, to keep project-data in sync.

data

cc.users is a dictionary with a full entry for the current user, and reduced metadata for all the other members.
cc.projects is a dictionary with a full entry for the current project.
cc.projects_members is a list with metadata for all project-member relations.
cc.languages available languages for internationalization and localization.

definitions is a dictionary holding all definitions for the project.
classes is a dictionary holding all classes for the project.
fields is a dictionary holding all fields for the project.
layouts is a dictionary holding all layouts for the project.
queries is a dictionary holding all queries for the project.

Error response

Note: You cannot authenticate successfully on this URL if you're not a member of this project.

400 Bad request - missing parameters (only the first is reported)
403 Forbidden - unknown user or wrong password

HTTP/1.1 400 Bad request

{
    "success": false,
    "result": {
        "code": 400,
        "message": "Bad request",
        "info": {
            "Missing parameter": "api_key"
        }
    },
    "data": {}
}
HTTP/1.1 403 Forbidden

{
    "success": false,
    "result": {
        "code": 403,
        "message": "Unknown user",
        "info": {}
    },
    "data": {}
}