Mint a one-shot pairing token for the connect helper
Creates a single-use pairing token surfaced in the dashboard as a npx @appstrate/[email protected] <token> command, pinned to the helper range this platform speaks. The user runs the command on their machine; the helper completes the loopback OAuth dance against the provider's authorization server, then POSTs the resulting credentials back to /api/model-providers-oauth/pair/redeem using this token as Bearer credentials. Two body shapes. A new connection sends owner_type, as on POST /api/model-provider-credentials: org (default) pairs an organization credential, which an organization model may be bound to and which then serves every caller; user pairs the caller's personal credential, serving only their own calls. A reconnect sends credentialId and no owner_type (the credential names its own owner, and the two together are a 400): it updates that exact credential in place, and is accepted exactly when the credential lists the reconnect action for the caller. The plaintext token is returned exactly once — only its SHA-256 hash is persisted. Permission: a new connection needs model-provider-credentials:write for owner_type: org, model-provider-credentials:connect for owner_type: user (403 otherwise, and 403 personal_model_credentials_disabled for user while the organization has personal_model_credentials off). A reconnect the caller may not make answers 404, except the caller's own personal credential while the organization has personal_model_credentials off, which answers 403 personal_model_credentials_disabled. Org-scoped: only X-Org-Id is required (no X-Space-Id — the resulting credential lives in model_provider_credentials, which has no space affinity).
/api/model-providers-oauth/pairingCookie session from Better Auth. Requires X-Org-Id header for org-scoped routes.
In: cookie
Header Parameters
Organization ID. Required for cookie auth. Not needed for API key auth (org resolved from key).
uuidRequest Body
application/json
curl -X POST "https://your-instance/api/model-providers-oauth/pairing" \ -H "Content-Type: application/json" \ -d '{ "providerId": "string" }'{
"id": "string",
"token": "string",
"command": "string",
"expiresAt": "2019-08-24T14:15:22Z"
}{
"type": "http://example.com",
"title": "string",
"status": 0,
"detail": "string",
"instance": "string",
"code": "string",
"request_id": "string",
"param": "string",
"retry_after": 0,
"errors": [
{
"field": "string",
"code": "string",
"message": "string",
"title": "string",
"line": 1,
"column": 1,
"candidate_connections": [
{
"id": "string",
"label": "string",
"account_id": "string",
"owned_by_actor": true,
"needs_reconnection": true,
"scopes_granted": [
"string"
],
"missing_scopes": [
"string"
]
}
],
"connection_id": "string",
"missing_scopes": [
"string"
],
"remedy": "new_connection",
"owned_by_actor": true,
"required_scopes": [
"string"
],
"auth_key": "string",
"required_auth_key": "string",
"available_auth_keys": [
"string"
],
"source": "admin_pin",
"connect_url": "http://example.com",
"expiresAt": "2019-08-24T14:15:22Z",
"packageId": "string"
}
]
}{
"type": "https://docs.appstrate.dev/errors/unauthorized",
"title": "Unauthorized",
"status": 401,
"detail": "Invalid or missing session",
"code": "unauthorized",
"request_id": "req_abc123"
}{
"type": "http://example.com",
"title": "string",
"status": 0,
"detail": "string",
"instance": "string",
"code": "string",
"request_id": "string",
"param": "string",
"retry_after": 0,
"errors": [
{
"field": "string",
"code": "string",
"message": "string",
"title": "string",
"line": 1,
"column": 1,
"candidate_connections": [
{
"id": "string",
"label": "string",
"account_id": "string",
"owned_by_actor": true,
"needs_reconnection": true,
"scopes_granted": [
"string"
],
"missing_scopes": [
"string"
]
}
],
"connection_id": "string",
"missing_scopes": [
"string"
],
"remedy": "new_connection",
"owned_by_actor": true,
"required_scopes": [
"string"
],
"auth_key": "string",
"required_auth_key": "string",
"available_auth_keys": [
"string"
],
"source": "admin_pin",
"connect_url": "http://example.com",
"expiresAt": "2019-08-24T14:15:22Z",
"packageId": "string"
}
]
}{
"type": "https://docs.appstrate.dev/errors/not-found",
"title": "Not Found",
"status": 404,
"detail": "Resource not found",
"code": "not_found",
"request_id": "req_abc123"
}{
"type": "https://docs.appstrate.dev/errors/rate-limited",
"title": "Rate Limited",
"status": 429,
"detail": "Too many requests. Please try again shortly.",
"code": "rate_limited",
"request_id": "req_abc123",
"retry_after": 30
}