Start a linked roles connection
Signed by an active device key of a card that already links a verified Discord account. Returns a random state bound to the card and the key, and Discord's consent page.
/v1/discord/linked-roles/start- Access
- Signed request
- Client
- Local or server client
Parameters#
| Name | Location | Meaning |
|---|---|---|
nRequired | JSON | The card's number. |
This call also needs the common signed-request headers, nonce and timestamp. Prepare and sign request.json before using the example. Request signing
Request examples#
curl -fsS -X POST \
-H "X-Public-Key: $PUBLIC_KEY" -H "X-Signature: $REQUEST_SIGNATURE" \
--json @request.json "https://veil.pub/v1/discord/linked-roles/start"Response#
201 {state, url, expiresAt, scopes}.
| Field | Type | Meaning |
|---|---|---|
state | string | 64 hex characters, ten minutes, once. |
url | string | Discord's consent page. |
expiresAt | string | When the state ends. |
scopes | array<string> | The scopes asked for. |
Response headers#
| Header | Value | Meaning |
|---|---|---|
Content-Type | application/json | JSON, also for errors. |
Cache-Control | no-store | Private: never cached. |
Errors#
API errors return an error object. Use error.code for program logic; error.message is English text for people and can change. Response and error guide
| HTTP | Code | Meaning and next step |
|---|---|---|
| 400 | invalid_parameter | A parameter is missing or malformed. Send n as the card's number, or returnCode as the 32 hex characters the page got. |
| 403 | key_mismatch | The key is not an active device key of the card, or not the key that started this connection. Sign with the device key of the browser that started. |
| 403 | veil_suspended | The Veil staff suspended the card. A suspended card gives no roles until the suspension ends. |
| 404 | linked_roles_off | This server does not offer Discord linked roles. Ask the server's operator, or check GET /v1/discord/linked-roles. |
| 404 | not_found | No such card or connection, or the connection is over. Start again from /discord/linked-roles. |
| 409 | discord_account_alert | The card declared this Discord account stolen, moved or no longer used, and has not declared it regained. On complete, the grant was revoked. Declare the account regained on the card, then connect. |
| 409 | not_in_good_standing | The card is closing, has a takeover open or its name is hidden. Settle that first, then connect. |
| 410 | erased | The card was closed. A closed card has no connections. |
| 422 | no_discord_link | The card has no verified Discord account. Link the Discord account to the card first. |
| 422 | not_for_organizations | Linked roles are for a person's card. Use a person's card. |
| 429 | too_many_starts | More than 20 connections started for this card in an hour. Every start counts, also the ones cancelled, finished or expired. Wait and try again. |
Shared request errors
| HTTP | Code | Meaning and next step |
|---|---|---|
| 400 | invalid_nonce | The signed-request nonce has an invalid format. Generate a fresh 16 to 128-character nonce using letters, digits, _ or -. |
| 400 | invalid_signature_alg |
Use a supported signing algorithm and matching key/signature encoding. |
| 400 | invalid_timestamp | The signed-request timestamp is not Unix milliseconds. Use an integer Unix timestamp in milliseconds and sign the corrected request. |
| 401 | invalid_signature | The HTTP request signature does not verify. Sign the exact method, path and body bytes, without changing them afterwards. |
| 401 | missing_signature | The request requires a device signature and its headers are missing or unreadable. Send |
| 401 | stale_timestamp | The signed timestamp is outside the accepted clock window. Compare the server Date header with your clock, then generate a fresh nonce, timestamp and signature. |
| 403 | key_banned | The device signing key is suspended by Veil staff. Use an authorised active key or ask staff to review the restriction. |
| 409 | replayed_nonce | The signing key already used this nonce. Check whether the previous request succeeded before making a fresh signed request. |
| 429 | rate_limited | An anonymous, signed-request or API-key allowance was exceeded. Wait at least |
| 500 | internal_error | An unexpected server error occurred. Internal details are not returned. Retry reads with bounded backoff. Check write results before sending a new signed operation. |
| 503 | busy | The application has reached a temporary concurrency or database limit. Wait |