Auth Code Create
The code-create endpoint is used to generate a short-lived authentication code. This code can be used to log in to the same network from a different device (e.g., entering a code on a TV or a constrained device) without manually entering full credentials.
POST /auth/code-create
Generate a temporary login code for use on other devices.
Request
POST /auth/code-create
Headers:
{
"Host": "api.bringyour.com",
"Authorization": "Bearer YOUR_JWT_TOKEN",
"Content-Type": "application/json"
}Body:
{
"duration_minutes": 10,
"uses": 1
}Fields
| Field | Type | Description |
|---|---|---|
duration_minutes | number | Optional. How long the code remains valid. Defaults to 10 minutes. |
uses | integer | Optional. Maximum number of times the code can be redeemed. Defaults to 1. |
Response
200 Success
Status: 200 OK
Content-Type: application/json
{
"auth_code": "string",
"duration_minutes": 0,
"uses": 0,
"error": {
"auth_code_limit_exceeded": false,
"message": "string"
}
}Fields
| Field | Type | Description |
|---|---|---|
auth_code | string | The generated alphanumeric login code. |
duration_minutes | number | Confirmed duration of validity. |
uses | integer | Confirmed maximum redemption count. |
error | object | Details on why the code could not be created. |
error.auth_code_limit_exceeded | boolean | True if the account has too many active pending codes. |
Example
HTTP Request
POST /auth/code-create HTTP/1.1
Host: api.bringyour.com
Authorization: Bearer YOUR_JWT_TOKEN
Content-Type: application/json
{
"duration_minutes": 15,
"uses": 1
}Successful HTTP Response
{
"auth_code": "BY-9876-5432",
"duration_minutes": 15,
"uses": 1,
"error": null
}