Skip to content
GurtOS

Pair a phone

POST
/pair
curl --request POST \
--url http://127.0.0.1:7700/api/pair \
--header 'Content-Type: application/json' \
--data '{ "code": "7f3a9c21", "name": "My phone" }'

A phone trades a pairing code for its own device token. The code stops working once used. Keep the token; the box does not show it again. Open without a token, so the body is capped at 1 MB. A code read off a screen may be typed as 8120-D849; case and dashes do not matter. Wrong codes are limited to 5 a minute from one address and 60 a minute from everyone together, then 429.

Media typeapplication/json
object
code
required

The code from POST /pair/start.

string
name

A name for the phone, shown in the log when it answers. Default phone.

string
<= 40 characters
kind

What the device says it is. Default web. It is never used for a security decision. setup goes with a code from POST /setup/code, and only with one.

string
Allowed values: web iphone mac setup
identity

Optional. The phone’s SpacetimeDB identity, so the box vouches for it at once.

string
/^[0-9a-fA-F]{64}$/

Example

{
"code": "7f3a9c21",
"name": "My phone"
}

The phone’s token.

Media typeapplication/json
object
token
required

The phone’s device token. Send it as Authorization: Bearer <token>.

string
edition

The box’s edition

string
Allowed values: server personal business
device
required
object
id
string
name
string
person

Business: the person the code was made for.

string
box
required
object
id
string
name
string

Example

{
"edition": "server"
}

The code is wrong, used or expired, or kind is not allowed.

Media typeapplication/json
object
error
required

What went wrong

string

Example

{
"error": "bad or expired pairing code"
}

The body is over 1 MB.

Media typeapplication/json
object
error
required

What went wrong

string

Example generated

{
"error": "example"
}

Too many wrong codes from this address, or from everyone together.

Media typeapplication/json
object
error
required

What went wrong

string

Example generated

{
"error": "example"
}