Hosted form credential submit (page cookie + CSRF)

Persists credentials entered on the hosted form — or, for an oauth2 auth (reached only when the integration declares connection variables), starts its OAuth flow with the submitted variables and returns the provider URL to navigate to; the connection is then created by the callback. Context + actor come from the page cookie; the request carries only the credentials and/or the variables and echoes the CSRF nonce in the x-connect-csrf header. An oauth2 refusal mirrors startIntegrationConnect: a variable to fix is a 400 validation_failed and the form can be resubmitted; another refusal keeps its status with a generic detail, and keeps the page session only when it preceded any request to the authorization server; anything else is a 502 that ends the session.

POST/api/integrations/connect/submit

Authorization

better-auth.session_token<token>

Cookie session from Better Auth. Requires X-Org-Id header for org-scoped routes.

In: cookie

Header Parameters

x-connect-csrf*string

Double-submit CSRF nonce (from GET /connect/context).

Request Body

application/json

curl -X POST "https://your-instance/api/integrations/connect/submit" \  -H "x-connect-csrf: string" \  -H "Content-Type: application/json" \  -d '{}'
{
  "ok": true,
  "connection": {
    "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
    "integration_package_id": "string",
    "auth_key": "string",
    "account_id": "string",
    "identity_claims": {},
    "scopes_granted": [
      "string"
    ],
    "needs_reconnection": true,
    "expiresAt": "2019-08-24T14:15:22Z",
    "owner_type": "user",
    "owner_id": "string",
    "owner_name": "string",
    "locked_by": "admin_pin",
    "label": "string",
    "shared_with_org": true,
    "client_ref": "string",
    "variables": {
      "property1": "string",
      "property2": "string"
    },
    "createdAt": "2019-08-24T14:15:22Z",
    "updatedAt": "2019-08-24T14:15:22Z"
  },
  "redirect_url": "http://example.com",
  "handoff_steps": [
    {
      "kind": "command",
      "id": "string",
      "label": "string",
      "shell": "string",
      "note": "string",
      "deferred": true
    }
  ]
}

{
  "type": "https://docs.appstrate.dev/errors/validation-failed",
  "title": "Validation Failed",
  "status": 400,
  "detail": "name: Invalid input: expected string, received undefined (+2 more)",
  "code": "validation_failed",
  "request_id": "req_abc123",
  "errors": [
    {
      "field": "name",
      "code": "required",
      "message": "Invalid input: expected string, received undefined"
    },
    {
      "field": "email",
      "code": "invalid_format",
      "message": "Invalid email address"
    },
    {
      "field": "age",
      "code": "invalid_type",
      "message": "Invalid input: expected number, received string"
    }
  ]
}

{
  "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",
      "candidate_connections": [
        {
          "id": "string",
          "label": "string",
          "account_id": "string",
          "owned_by_actor": true,
          "needs_reconnection": true
        }
      ],
      "connection_id": "string",
      "missing_scopes": [
        "string"
      ],
      "owned_by_actor": true,
      "required_scopes": [
        "string"
      ],
      "auth_key": "string",
      "required_auth_key": "string",
      "available_auth_keys": [
        "string"
      ],
      "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
}
{
  "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",
      "candidate_connections": [
        {
          "id": "string",
          "label": "string",
          "account_id": "string",
          "owned_by_actor": true,
          "needs_reconnection": true
        }
      ],
      "connection_id": "string",
      "missing_scopes": [
        "string"
      ],
      "owned_by_actor": true,
      "required_scopes": [
        "string"
      ],
      "auth_key": "string",
      "required_auth_key": "string",
      "available_auth_keys": [
        "string"
      ],
      "connect_url": "http://example.com",
      "expiresAt": "2019-08-24T14:15:22Z",
      "packageId": "string"
    }
  ]
}
{
  "type": "https://docs.appstrate.dev/errors/connect-unavailable",
  "title": "Service Unavailable",
  "status": 503,
  "detail": "This connection method is unavailable on this deployment. Contact your administrator.",
  "code": "connect_unavailable",
  "request_id": "req_abc123"
}
{
  "type": "https://docs.appstrate.dev/errors/timeout",
  "title": "Gateway Timeout",
  "status": 504,
  "detail": "The connection attempt timed out after 60000ms — the login did not complete in time. Please try again.",
  "code": "timeout",
  "request_id": "req_def456"
}