Poll a sign-in from a terminal

Where a sign-in stands, and its tokens once it is approved

POST/v1/cli/logins/token

Where a sign-in started from a terminal stands, by its deviceCode. It takes no credential and reads no x-mapier-version. An unknown device code is a 404.

statusMeans
pendingNobody has approved or denied it yet. Poll after interval
slow_downYou polled too soon; interval has grown. Wait it out
deniedThe person denied it. Start again
expiredTen minutes passed before the tokens were handed over
usedIts tokens were already handed over. Start again
approvedApproved: this answer carries the tokens

approved is answered once, to the first poll after the approval, and carries two tokens. accessToken is a personal access token to send as the bearer, which lasts an hour. refreshToken is never a bearer: exchange it at POST /v1/cli/tokens/renew for a new pair. Store both now; no request returns either again.

The sign-in carries every scope the person's role allowed when they approved, every project, live, and ends 60 days later however often it renews. A person who already holds ten active tokens in that organization gets a 409 limit_reached: once they revoke one, the next poll succeeds while the login lasts.

Example request

curl -X POST https://api.mapier.ai/v1/cli/logins/token \
  -H "Content-Type: application/json" \
  -d '{ "deviceCode": "mp_cli_example-not-a-real-device-code" }'

Response

200 OK — before anyone approves
{ "status": "pending", "interval": 5 }
200 OK — approved, once
{
  "status": "approved",
  "accessToken": "mp_pat_example-not-a-real-token",
  "accessTokenExpiresAt": "2026-09-02T15:12:00.000Z",
  "refreshToken": "mp_refresh_example-not-a-real-token",
  "refreshTokenExpiresAt": "2026-11-01T14:12:00.000Z",
  "tokenId": "0192a7f3-6f70-7182-9d93-0f1a2b3c4d5e",
  "organization": {
    "id": "0192a7a0-0b1c-7d2e-8f3a-4b5c6d7e8f90",
    "slug": "acme",
    "name": "Acme"
  },
  "role": "developer",
  "scopes": ["projects:read", "projects:write", "messages:read", "messages:send"]
}

role is the role its owner holds in the organization now; the token never does more. tokenId is the sign-in as the console lists it, the same across renewals.

Errors

StatusCodeReasonWhenChannels
400bad_requestThe body is not valid JSON, the channel rejected the request as malformed, or a header the call needs is missing.All
404not_foundNothing with that id exists in this project.All
409limit_reachedA limit is reached: a test line's daily cap, or the dedicated lines your organization pays for.All
413payload_too_largeThe body is over 65,536 bytes.All
422validation_failedA field is wrong, and details names each one at its path.All
429rate_limitedToo many requests for this route's budget.All
500internal_errorMapier failed on its side, and has been alerted.All
503upstream_unavailableThe channel did not take the command, or gave no answer Mapier could use.All