<!-- Generated from the reviewed public OpenAPI contract. Do not edit this file. -->

# Start RFC 8628 device authorization


**POST** ` /v1/oauth/device/authorize `


See https://ordan.io/docs/authentication and https://ordan.io/docs/errors for authority, scopes and retries. Paid usage reports customer charges; preview usage reports provider-cost allowance consumption. Money fields use the units specified in their schemas.

Operation ID: ` post__v1_oauth_device_authorize `.

## Authentication

No session or bearer credential is required by this operation. Required token/body fields still apply.

## Request

### Body (required)



**Content type:** ` application/json `

**Type:** object

Required means required **within its containing object**, when that object is present. Union/conditional constraints remain defined by the JSON Schema below.


| Field | Type | Presence | Description / constraints |
| --- | --- | --- | --- |
| ` agent_name ` | string | Required | minLength: ` 1 `. maxLength: ` 120 ` |
| ` org ` | string | Optional | Public org_… reference (not a UUID). pattern: ` ^org_[0-7][0-9A-HJKMNP-TV-Z]{25}$ ` |
| ` policy ` | string | Optional | Public pol_… reference (not a UUID). pattern: ` ^pol_[0-7][0-9A-HJKMNP-TV-Z]{25}$ ` |
| ` project ` | string | Optional | Public proj_… reference (not a UUID). pattern: ` ^proj_[0-7][0-9A-HJKMNP-TV-Z]{25}$ ` |
| ` requested_capabilities ` | Array of ` voice.outbound `, ` voice.inbound `, ` sms.send `, ` sms.receive `, ` numbers.provision `, ` numbers.release `, ` calls.transfer `, ` calls.hangup `, ` calls.record `, ` calls.dtmf `, ` purchases `, ` policy.check `, ` usage.read `, ` events.read ` | Required | minItems: ` 1 ` |
| ` spend_limit_cents ` | integer | Optional | minimum: ` 1 ` |


**JSON Schema**
```json
{
  "additionalProperties": true,
  "properties": {
    "agent_name": {
      "maxLength": 120,
      "minLength": 1,
      "type": "string"
    },
    "org": {
      "description": "Public org_… reference (not a UUID)",
      "pattern": "^org_[0-7][0-9A-HJKMNP-TV-Z]{25}$",
      "type": "string"
    },
    "policy": {
      "description": "Public pol_… reference (not a UUID)",
      "pattern": "^pol_[0-7][0-9A-HJKMNP-TV-Z]{25}$",
      "type": "string"
    },
    "project": {
      "description": "Public proj_… reference (not a UUID)",
      "pattern": "^proj_[0-7][0-9A-HJKMNP-TV-Z]{25}$",
      "type": "string"
    },
    "requested_capabilities": {
      "items": {
        "enum": [
          "voice.outbound",
          "voice.inbound",
          "sms.send",
          "sms.receive",
          "numbers.provision",
          "numbers.release",
          "calls.transfer",
          "calls.hangup",
          "calls.record",
          "calls.dtmf",
          "purchases",
          "policy.check",
          "usage.read",
          "events.read"
        ],
        "type": "string"
      },
      "minItems": 1,
      "type": "array"
    },
    "spend_limit_cents": {
      "minimum": 1,
      "type": "integer"
    }
  },
  "required": [
    "agent_name",
    "requested_capabilities"
  ],
  "type": "object"
}
```

## Request examples

These are **request templates**, not executed requests. Replace `REPLACE_…` and `<…>` placeholders, set the credential environment variables, and supply any conditional fields your action needs. JSON values are illustrative, not live records. Use a stable idempotency key per logical operation.

```bash
curl --request POST --url 'https://api.ordan.io/v1/oauth/device/authorize' \
  --header "Content-Type: application/json" \
  --data-raw '{
  "agent_name": "<agent_name>",
  "requested_capabilities": [
    "voice.outbound"
  ]
}'
```

```js
const response = await fetch("https://api.ordan.io/v1/oauth/device/authorize", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
  "agent_name": "<agent_name>",
  "requested_capabilities": [
    "voice.outbound"
  ]
}),
});
const text = await response.text();
if (!response.ok) throw new Error(`${response.status}: ${text}`);
const result = text ? JSON.parse(text) : null;
```

```python
import json
import os
from urllib.request import Request, urlopen

request = Request("https://api.ordan.io/v1/oauth/device/authorize",
    method="POST",
    headers={
        "Content-Type": "application/json",
    },
    data="{\n  \"agent_name\": \"<agent_name>\",\n  \"requested_capabilities\": [\n    \"voice.outbound\"\n  ]\n}".encode("utf-8"),
)
with urlopen(request, timeout=30) as response:
    text = response.read().decode("utf-8")
    result = json.loads(text) if text else None
```

## Responses

| Status | Meaning |
| --- | --- |
| ` 400 ` | Invalid request; device token polling uses RFC 8628 string errors |
| ` 402 ` | spend_limit_exceeded: inspect details.scope (org/grant/line) and outstanding_micros |
| ` 403 ` | Missing authority, policy_violation, approval_required (details.approval_request), limit_reached, destination_not_supported or feature_disabled (details.feature) |
| ` 409 ` | Conflict, idempotency in progress, or a2p_registration_pending; retrieve state instead of duplicating work |
| ` 422 ` | validation_error: the request is not valid; details name each field |
| ` 429 ` | Rate limited; back off and retain the same idempotency key |
| ` 502 ` | provider_error: unknown routes need verified quotes; ambiguous operations retain resource references and cost holds |
| ` 2XX ` | Success (created objects use 201) |
| ` default ` | Error |

Status ranges such as `2XX` are retained exactly as declared. See [Errors and recovery](../errors.md) for retries and pending outcomes.

### 400 response

**Content type:** ` application/json `

**Type:** [Error](schemas/error.md)

Required means required **within its containing object**, when that object is present. Union/conditional constraints remain defined by the JSON Schema below.


| Field | Type | Presence | Description / constraints |
| --- | --- | --- | --- |
| ` error ` | object | Required | Additional properties allowed |
| ` error.code ` | string | Required | — |
| ` error.details ` | object | Optional | Additional properties allowed |
| ` error.message ` | string | Required | — |


**JSON Schema**
```json
{
  "$ref": "#/components/schemas/Error"
}
```

### 2XX response

**Content type:** ` application/json `

**Type:** [DeviceAuthorization](schemas/deviceauthorization.md)

Required means required **within its containing object**, when that object is present. Union/conditional constraints remain defined by the JSON Schema below.


| Field | Type | Presence | Description / constraints |
| --- | --- | --- | --- |
| ` device_code ` | string | Optional | writeOnly |
| ` expires_in ` | integer | Optional | minimum: ` 0 ` |
| ` interval ` | integer | Optional | minimum: ` 0 ` |
| ` user_code ` | string | Optional | — |
| ` verification_uri ` | string (uri) | Optional | — |


**JSON Schema**
```json
{
  "$ref": "#/components/schemas/DeviceAuthorization"
}
```

**Illustrative response template**
Placeholder values show the shape, not a live response. Nullable costs remain null rather than implying zero usage.

```json
{
  "expires_in": 0,
  "interval": 0,
  "user_code": "<user_code>",
  "verification_uri": "<verification_uri>"
}
```

### default response

**Content type:** ` application/json `

**Type:** [Error](schemas/error.md)

Required means required **within its containing object**, when that object is present. Union/conditional constraints remain defined by the JSON Schema below.


| Field | Type | Presence | Description / constraints |
| --- | --- | --- | --- |
| ` error ` | object | Required | Additional properties allowed |
| ` error.code ` | string | Required | — |
| ` error.details ` | object | Optional | Additional properties allowed |
| ` error.message ` | string | Required | — |


**JSON Schema**
```json
{
  "$ref": "#/components/schemas/Error"
}
```
