Open plinto
Docs›Guides

API tokens and limits

Guide·4 min read

plinto login gives your terminal a key for a day, from your SSH key. It asks for what plinto and the editors do alone: builds, runs, dry runs, reviews, imports and plinto reproduce, whoever you are. A script or a CI job needs a key that lasts, without an SSH key, and asks for more: an API token. You make it in plinto code, under API tokens in your user menu.

Making one

A token has:

A token with specific permissions does what you tick alone, as the organization's admin, and gets 403 for anything else, so a script that needs one thing can't do more if it leaks. There is one so far:

Permission Lets it
Register hosts make setup lines for new servers: see Hosts, From a script

plinto shows the token once, as you make it: plinto_ and 40 letters and digits. Copy it into your CI's secrets. If you lose it, revoke it and make another. Making one asks for your second factor when you haven't given it in the last few minutes, as adding an SSH key does.

Using it

It goes where plinto login's key goes, and asks for whatever its access lets it.

With curl, or any HTTP client, as the X-Plinto-Key header:

$ curl -H "X-Plinto-Key: $PLINTO_TOKEN" https://repository.plinto.build/acme/version-groups/main

With plinto, in PLINTO_ACCESS_KEY:

$ PLINTO_ACCESS_KEY=$PLINTO_TOKEN plinto build -a

With git over HTTPS, as the password (any user name):

$ git clone https://x:$PLINTO_TOKEN@build-service.plinto.build/git/acme/Billing.git

plinto never renews a token: when one is refused, it says why and to make a new one.

Revoking

Revoke on the API tokens page stops a token from its next request on. Each token's row says when and from where it was last used.

Tokens stop on their own when:

Making and revoking a token show in your Recent activity, on the Two-factor sign-in page.

API limits

Programs, tokens and plinto login's keys alike, may make so many requests a second. The apps in your browser never count. Each request takes one from three buckets of its organization's:

Bucket Default
The organization 10 a second everything its keys and tokens ask
An API site 5 a second repository., build-service. and hosts.plinto.build, each
A group of endpoints 3 a second such as downloads, metadata, builds or git

Each bucket also holds a minute's worth at once, so a cold build on a fresh machine gets through. Over a limit, the answer is 429 Too Many Requests, with Retry-After (the seconds until there is room again) and X-Plinto-Limited (which bucket is empty):

HTTP/1.1 429 Too Many Requests
Retry-After: 1
X-Plinto-Limited: group

{"error": "acme's API limit for downloads: 3 a second, a burst of 180; try again in 1 s", …}

plinto and the editors wait out such a 429 and send again, for up to two minutes, saying so once. A script should do the same: wait Retry-After seconds, and a little more. plinto's admins can give an organization higher limits.