# Authentication API

Inspect the authenticated principal and look up organization IDs.

## Get organization IDs from the token or the first WorkOS membership page

`GET /api/cli/org`

Accepts only a WorkOS user access token: a Factory API key, including a service account's, is answered 401, as is a request without a bearer credential or with a token whose signature does not verify. For a token that carries a WorkOS organization, returns that organization alone; otherwise returns organization IDs from only the first page of WorkOS memberships for the token's user (active ones, up to 10, under WorkOS's current defaults), without following or returning a pagination cursor. A 429 passes on WorkOS rate limiting of that list. A 503 means WorkOS could not serve the request: its signing keys could not be fetched to check the token, or the list answered a server error or bad JSON, or was unreachable.

```bash
curl 'https://api.factory.ai/api/cli/org' \
  -H "Authorization: Bearer $FACTORY_BEARER_TOKEN"
```

**Parameters**

- `X-Factory-Org-Id` (`string`) - Header parameter. Ignored: the answer depends only on the bearer token.

**Response:** `200` - Response for status 200

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "workosOrgIds": {
      "type": "array",
      "items": {
        "type": "string"
      }
    }
  },
  "required": [
    "workosOrgIds"
  ]
}
```

**Response:** `400` - Response for status 400

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `401` - Response for status 401

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `402` - Response for status 402

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `403` - Response for status 403

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `404` - Response for status 404

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `409` - Response for status 409

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `410` - Response for status 410

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `413` - Response for status 413

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `422` - Response for status 422

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `429` - Response for status 429

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `451` - Response for status 451

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `500` - Response for status 500

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `502` - Response for status 502

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `503` - Response for status 503

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

## Get the authenticated principal

`GET /api/cli/whoami`

Returns the principal a user access token, a user API key or a service account API key authenticates, and the organization the request acts in.

```bash
curl 'https://api.factory.ai/api/cli/whoami' \
  -H "Authorization: Bearer $FACTORY_BEARER_TOKEN"
```

**Parameters**

- `X-Factory-Whoami-Extended` (`string`) - Header parameter. With `true`, the answer adds `inferenceRegion`, `isEnterprise` and `principalKind`, and `premBaseHostV2` unless the credential is an environment repair credential. Without the header, the answer carries none of them. Allowed values: true.
- `X-Factory-Session-Attribution` (`string`) - Header parameter. A session attribution claim. A claim signed for this principal and organization that has not expired is returned as `attribution`, unless the signing key cannot be read in time. A claim with a bad signature, signed for another principal or another organization, or expired is ignored.
- `X-Factory-Org-Id` (`string`) - Header parameter. For a user who can access their root organization, a request without the header, or with one naming an organization the user cannot access, acts in the root organization. An API key acts in its own organization and ignores this header.

**Response:** `200` - Response for status 200

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "userId": {
      "type": "string",
      "minLength": 1,
      "description": "For a user access token or a user API key, the user's ID; for a service account API key, the service account's ID."
    },
    "orgId": {
      "type": "string",
      "minLength": 1,
      "description": "For an API key, the key's organization; for a user access token, the organization the request acts in, as `X-Factory-Org-Id` describes."
    },
    "region": {
      "type": "string",
      "enum": [
        "global",
        "eu"
      ]
    },
    "inferenceRegion": {
      "type": "string",
      "enum": [
        "global",
        "eu",
        "us",
        "in"
      ]
    },
    "isEnterprise": {
      "type": "boolean"
    },
    "principalKind": {
      "type": "string",
      "enum": [
        "human",
        "service"
      ],
      "description": "`human` for a user access token or a user API key, `service` for a service account API key."
    },
    "premBaseHostV2": {
      "type": "string"
    },
    "attribution": {
      "type": "object",
      "properties": {
        "userId": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "source": {
          "type": "string",
          "enum": [
            "web",
            "desktop",
            "cli_tui",
            "cli_exec",
            "cli_acp",
            "slack",
            "jira",
            "linear",
            "microsoft-teams",
            "google-chat",
            "sessions_api",
            "api",
            "sdk",
            "automation",
            "readiness-remediation",
            "readiness-evaluation",
            "wiki-generation",
            "wiki-ci-setup"
          ]
        },
        "receipt": {
          "type": "string"
        },
        "sessionId": {
          "type": "string",
          "minLength": 1
        }
      },
      "required": [
        "userId",
        "sessionId"
      ]
    }
  },
  "required": [
    "userId",
    "orgId"
  ]
}
```

**Response:** `400` - Response for status 400

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `401` - Response for status 401

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `402` - Response for status 402

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `403` - Response for status 403

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `404` - Response for status 404

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `451` - Response for status 451

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `500` - Response for status 500

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `503` - Response for status 503

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```
