Authentication API

Inspect the authenticated principal and look up organization IDs.

GET/api/cli/org

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

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.

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

Parameters

X-Factory-Org-Idstringheaderoptional

Ignored: the answer depends only on the bearer token.

Responses

200Response for status 200

application/json

workosOrgIdsstring[]required

Array items

string
400Response for status 400

application/json

detailstringrequired

Human-readable error message

statusnumberrequired

HTTP status code

titlestringrequired

HTTP status title

metadataobject (map)

Additional error metadata

Values

object
requestIdstring

Request identifier to include when contacting support

codestring

Stable machine-readable error code, when one applies

displayToUserboolean

True when detail is curated copy that is safe to show users

errorobject

The same error fields, for clients that only read body.error

detailstringrequired

Human-readable error message

statusnumberrequired

HTTP status code

titlestringrequired

HTTP status title

metadataobject (map)

Additional error metadata

Values

object
requestIdstring

Request identifier to include when contacting support

codestring

Stable machine-readable error code, when one applies

displayToUserboolean

True when detail is curated copy that is safe to show users

401Response for status 401

application/json

detailstringrequired

Human-readable error message

statusnumberrequired

HTTP status code

titlestringrequired

HTTP status title

metadataobject (map)

Additional error metadata

Values

object
requestIdstring

Request identifier to include when contacting support

codestring

Stable machine-readable error code, when one applies

displayToUserboolean

True when detail is curated copy that is safe to show users

errorobject

The same error fields, for clients that only read body.error

detailstringrequired

Human-readable error message

statusnumberrequired

HTTP status code

titlestringrequired

HTTP status title

metadataobject (map)

Additional error metadata

Values

object
requestIdstring

Request identifier to include when contacting support

codestring

Stable machine-readable error code, when one applies

displayToUserboolean

True when detail is curated copy that is safe to show users

402Response for status 402

application/json

detailstringrequired

Human-readable error message

statusnumberrequired

HTTP status code

titlestringrequired

HTTP status title

metadataobject (map)

Additional error metadata

Values

object
requestIdstring

Request identifier to include when contacting support

codestring

Stable machine-readable error code, when one applies

displayToUserboolean

True when detail is curated copy that is safe to show users

errorobject

The same error fields, for clients that only read body.error

detailstringrequired

Human-readable error message

statusnumberrequired

HTTP status code

titlestringrequired

HTTP status title

metadataobject (map)

Additional error metadata

Values

object
requestIdstring

Request identifier to include when contacting support

codestring

Stable machine-readable error code, when one applies

displayToUserboolean

True when detail is curated copy that is safe to show users

403Response for status 403

application/json

detailstringrequired

Human-readable error message

statusnumberrequired

HTTP status code

titlestringrequired

HTTP status title

metadataobject (map)

Additional error metadata

Values

object
requestIdstring

Request identifier to include when contacting support

codestring

Stable machine-readable error code, when one applies

displayToUserboolean

True when detail is curated copy that is safe to show users

errorobject

The same error fields, for clients that only read body.error

detailstringrequired

Human-readable error message

statusnumberrequired

HTTP status code

titlestringrequired

HTTP status title

metadataobject (map)

Additional error metadata

Values

object
requestIdstring

Request identifier to include when contacting support

codestring

Stable machine-readable error code, when one applies

displayToUserboolean

True when detail is curated copy that is safe to show users

404Response for status 404

application/json

detailstringrequired

Human-readable error message

statusnumberrequired

HTTP status code

titlestringrequired

HTTP status title

metadataobject (map)

Additional error metadata

Values

object
requestIdstring

Request identifier to include when contacting support

codestring

Stable machine-readable error code, when one applies

displayToUserboolean

True when detail is curated copy that is safe to show users

errorobject

The same error fields, for clients that only read body.error

detailstringrequired

Human-readable error message

statusnumberrequired

HTTP status code

titlestringrequired

HTTP status title

metadataobject (map)

Additional error metadata

Values

object
requestIdstring

Request identifier to include when contacting support

codestring

Stable machine-readable error code, when one applies

displayToUserboolean

True when detail is curated copy that is safe to show users

409Response for status 409

application/json

detailstringrequired

Human-readable error message

statusnumberrequired

HTTP status code

titlestringrequired

HTTP status title

metadataobject (map)

Additional error metadata

Values

object
requestIdstring

Request identifier to include when contacting support

codestring

Stable machine-readable error code, when one applies

displayToUserboolean

True when detail is curated copy that is safe to show users

errorobject

The same error fields, for clients that only read body.error

detailstringrequired

Human-readable error message

statusnumberrequired

HTTP status code

titlestringrequired

HTTP status title

metadataobject (map)

Additional error metadata

Values

object
requestIdstring

Request identifier to include when contacting support

codestring

Stable machine-readable error code, when one applies

displayToUserboolean

True when detail is curated copy that is safe to show users

410Response for status 410

application/json

detailstringrequired

Human-readable error message

statusnumberrequired

HTTP status code

titlestringrequired

HTTP status title

metadataobject (map)

Additional error metadata

Values

object
requestIdstring

Request identifier to include when contacting support

codestring

Stable machine-readable error code, when one applies

displayToUserboolean

True when detail is curated copy that is safe to show users

errorobject

The same error fields, for clients that only read body.error

detailstringrequired

Human-readable error message

statusnumberrequired

HTTP status code

titlestringrequired

HTTP status title

metadataobject (map)

Additional error metadata

Values

object
requestIdstring

Request identifier to include when contacting support

codestring

Stable machine-readable error code, when one applies

displayToUserboolean

True when detail is curated copy that is safe to show users

413Response for status 413

application/json

detailstringrequired

Human-readable error message

statusnumberrequired

HTTP status code

titlestringrequired

HTTP status title

metadataobject (map)

Additional error metadata

Values

object
requestIdstring

Request identifier to include when contacting support

codestring

Stable machine-readable error code, when one applies

displayToUserboolean

True when detail is curated copy that is safe to show users

errorobject

The same error fields, for clients that only read body.error

detailstringrequired

Human-readable error message

statusnumberrequired

HTTP status code

titlestringrequired

HTTP status title

metadataobject (map)

Additional error metadata

Values

object
requestIdstring

Request identifier to include when contacting support

codestring

Stable machine-readable error code, when one applies

displayToUserboolean

True when detail is curated copy that is safe to show users

422Response for status 422

application/json

detailstringrequired

Human-readable error message

statusnumberrequired

HTTP status code

titlestringrequired

HTTP status title

metadataobject (map)

Additional error metadata

Values

object
requestIdstring

Request identifier to include when contacting support

codestring

Stable machine-readable error code, when one applies

displayToUserboolean

True when detail is curated copy that is safe to show users

errorobject

The same error fields, for clients that only read body.error

detailstringrequired

Human-readable error message

statusnumberrequired

HTTP status code

titlestringrequired

HTTP status title

metadataobject (map)

Additional error metadata

Values

object
requestIdstring

Request identifier to include when contacting support

codestring

Stable machine-readable error code, when one applies

displayToUserboolean

True when detail is curated copy that is safe to show users

429Response for status 429

application/json

detailstringrequired

Human-readable error message

statusnumberrequired

HTTP status code

titlestringrequired

HTTP status title

metadataobject (map)

Additional error metadata

Values

object
requestIdstring

Request identifier to include when contacting support

codestring

Stable machine-readable error code, when one applies

displayToUserboolean

True when detail is curated copy that is safe to show users

errorobject

The same error fields, for clients that only read body.error

detailstringrequired

Human-readable error message

statusnumberrequired

HTTP status code

titlestringrequired

HTTP status title

metadataobject (map)

Additional error metadata

Values

object
requestIdstring

Request identifier to include when contacting support

codestring

Stable machine-readable error code, when one applies

displayToUserboolean

True when detail is curated copy that is safe to show users

451Response for status 451

application/json

detailstringrequired

Human-readable error message

statusnumberrequired

HTTP status code

titlestringrequired

HTTP status title

metadataobject (map)

Additional error metadata

Values

object
requestIdstring

Request identifier to include when contacting support

codestring

Stable machine-readable error code, when one applies

displayToUserboolean

True when detail is curated copy that is safe to show users

errorobject

The same error fields, for clients that only read body.error

detailstringrequired

Human-readable error message

statusnumberrequired

HTTP status code

titlestringrequired

HTTP status title

metadataobject (map)

Additional error metadata

Values

object
requestIdstring

Request identifier to include when contacting support

codestring

Stable machine-readable error code, when one applies

displayToUserboolean

True when detail is curated copy that is safe to show users

500Response for status 500

application/json

detailstringrequired

Human-readable error message

statusnumberrequired

HTTP status code

titlestringrequired

HTTP status title

metadataobject (map)

Additional error metadata

Values

object
requestIdstring

Request identifier to include when contacting support

codestring

Stable machine-readable error code, when one applies

displayToUserboolean

True when detail is curated copy that is safe to show users

errorobject

The same error fields, for clients that only read body.error

detailstringrequired

Human-readable error message

statusnumberrequired

HTTP status code

titlestringrequired

HTTP status title

metadataobject (map)

Additional error metadata

Values

object
requestIdstring

Request identifier to include when contacting support

codestring

Stable machine-readable error code, when one applies

displayToUserboolean

True when detail is curated copy that is safe to show users

502Response for status 502

application/json

detailstringrequired

Human-readable error message

statusnumberrequired

HTTP status code

titlestringrequired

HTTP status title

metadataobject (map)

Additional error metadata

Values

object
requestIdstring

Request identifier to include when contacting support

codestring

Stable machine-readable error code, when one applies

displayToUserboolean

True when detail is curated copy that is safe to show users

errorobject

The same error fields, for clients that only read body.error

detailstringrequired

Human-readable error message

statusnumberrequired

HTTP status code

titlestringrequired

HTTP status title

metadataobject (map)

Additional error metadata

Values

object
requestIdstring

Request identifier to include when contacting support

codestring

Stable machine-readable error code, when one applies

displayToUserboolean

True when detail is curated copy that is safe to show users

503Response for status 503

application/json

detailstringrequired

Human-readable error message

statusnumberrequired

HTTP status code

titlestringrequired

HTTP status title

metadataobject (map)

Additional error metadata

Values

object
requestIdstring

Request identifier to include when contacting support

codestring

Stable machine-readable error code, when one applies

displayToUserboolean

True when detail is curated copy that is safe to show users

errorobject

The same error fields, for clients that only read body.error

detailstringrequired

Human-readable error message

statusnumberrequired

HTTP status code

titlestringrequired

HTTP status title

metadataobject (map)

Additional error metadata

Values

object
requestIdstring

Request identifier to include when contacting support

codestring

Stable machine-readable error code, when one applies

displayToUserboolean

True when detail is curated copy that is safe to show users

GET/api/cli/whoami

Get the authenticated principal

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.

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

Parameters

X-Factory-Whoami-Extendedstringheaderoptional

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-Attributionstringheaderoptional

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-Idstringheaderoptional

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.

Responses

200Response for status 200

application/json

userIdstringrequired

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.

Minimum length: 1

orgIdstringrequired

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.

Minimum length: 1

regionstring

Allowed values

globaleu
inferenceRegionstring

Allowed values

globaleuusin
isEnterpriseboolean
principalKindstring

`human` for a user access token or a user API key, `service` for a service account API key.

Allowed values

humanservice
premBaseHostV2string
attributionobject
userIdstringrequired
namestring
sourcestring

Allowed values

webdesktopcli_tuicli_execcli_acpslackjiralinearmicrosoft-teamsgoogle-chatsessions_apiapisdkautomationreadiness-remediationreadiness-evaluationwiki-generationwiki-ci-setup
receiptstring
sessionIdstringrequired

Minimum length: 1

400Response for status 400

application/json

detailstringrequired

Human-readable error message

statusnumberrequired

HTTP status code

titlestringrequired

HTTP status title

metadataobject (map)

Additional error metadata

Values

object
requestIdstring

Request identifier to include when contacting support

codestring

Stable machine-readable error code, when one applies

displayToUserboolean

True when detail is curated copy that is safe to show users

errorobject

The same error fields, for clients that only read body.error

detailstringrequired

Human-readable error message

statusnumberrequired

HTTP status code

titlestringrequired

HTTP status title

metadataobject (map)

Additional error metadata

Values

object
requestIdstring

Request identifier to include when contacting support

codestring

Stable machine-readable error code, when one applies

displayToUserboolean

True when detail is curated copy that is safe to show users

401Response for status 401

application/json

detailstringrequired

Human-readable error message

statusnumberrequired

HTTP status code

titlestringrequired

HTTP status title

metadataobject (map)

Additional error metadata

Values

object
requestIdstring

Request identifier to include when contacting support

codestring

Stable machine-readable error code, when one applies

displayToUserboolean

True when detail is curated copy that is safe to show users

errorobject

The same error fields, for clients that only read body.error

detailstringrequired

Human-readable error message

statusnumberrequired

HTTP status code

titlestringrequired

HTTP status title

metadataobject (map)

Additional error metadata

Values

object
requestIdstring

Request identifier to include when contacting support

codestring

Stable machine-readable error code, when one applies

displayToUserboolean

True when detail is curated copy that is safe to show users

402Response for status 402

application/json

detailstringrequired

Human-readable error message

statusnumberrequired

HTTP status code

titlestringrequired

HTTP status title

metadataobject (map)

Additional error metadata

Values

object
requestIdstring

Request identifier to include when contacting support

codestring

Stable machine-readable error code, when one applies

displayToUserboolean

True when detail is curated copy that is safe to show users

errorobject

The same error fields, for clients that only read body.error

detailstringrequired

Human-readable error message

statusnumberrequired

HTTP status code

titlestringrequired

HTTP status title

metadataobject (map)

Additional error metadata

Values

object
requestIdstring

Request identifier to include when contacting support

codestring

Stable machine-readable error code, when one applies

displayToUserboolean

True when detail is curated copy that is safe to show users

403Response for status 403

application/json

detailstringrequired

Human-readable error message

statusnumberrequired

HTTP status code

titlestringrequired

HTTP status title

metadataobject (map)

Additional error metadata

Values

object
requestIdstring

Request identifier to include when contacting support

codestring

Stable machine-readable error code, when one applies

displayToUserboolean

True when detail is curated copy that is safe to show users

errorobject

The same error fields, for clients that only read body.error

detailstringrequired

Human-readable error message

statusnumberrequired

HTTP status code

titlestringrequired

HTTP status title

metadataobject (map)

Additional error metadata

Values

object
requestIdstring

Request identifier to include when contacting support

codestring

Stable machine-readable error code, when one applies

displayToUserboolean

True when detail is curated copy that is safe to show users

404Response for status 404

application/json

detailstringrequired

Human-readable error message

statusnumberrequired

HTTP status code

titlestringrequired

HTTP status title

metadataobject (map)

Additional error metadata

Values

object
requestIdstring

Request identifier to include when contacting support

codestring

Stable machine-readable error code, when one applies

displayToUserboolean

True when detail is curated copy that is safe to show users

errorobject

The same error fields, for clients that only read body.error

detailstringrequired

Human-readable error message

statusnumberrequired

HTTP status code

titlestringrequired

HTTP status title

metadataobject (map)

Additional error metadata

Values

object
requestIdstring

Request identifier to include when contacting support

codestring

Stable machine-readable error code, when one applies

displayToUserboolean

True when detail is curated copy that is safe to show users

451Response for status 451

application/json

detailstringrequired

Human-readable error message

statusnumberrequired

HTTP status code

titlestringrequired

HTTP status title

metadataobject (map)

Additional error metadata

Values

object
requestIdstring

Request identifier to include when contacting support

codestring

Stable machine-readable error code, when one applies

displayToUserboolean

True when detail is curated copy that is safe to show users

errorobject

The same error fields, for clients that only read body.error

detailstringrequired

Human-readable error message

statusnumberrequired

HTTP status code

titlestringrequired

HTTP status title

metadataobject (map)

Additional error metadata

Values

object
requestIdstring

Request identifier to include when contacting support

codestring

Stable machine-readable error code, when one applies

displayToUserboolean

True when detail is curated copy that is safe to show users

500Response for status 500

application/json

detailstringrequired

Human-readable error message

statusnumberrequired

HTTP status code

titlestringrequired

HTTP status title

metadataobject (map)

Additional error metadata

Values

object
requestIdstring

Request identifier to include when contacting support

codestring

Stable machine-readable error code, when one applies

displayToUserboolean

True when detail is curated copy that is safe to show users

errorobject

The same error fields, for clients that only read body.error

detailstringrequired

Human-readable error message

statusnumberrequired

HTTP status code

titlestringrequired

HTTP status title

metadataobject (map)

Additional error metadata

Values

object
requestIdstring

Request identifier to include when contacting support

codestring

Stable machine-readable error code, when one applies

displayToUserboolean

True when detail is curated copy that is safe to show users

503Response for status 503

application/json

detailstringrequired

Human-readable error message

statusnumberrequired

HTTP status code

titlestringrequired

HTTP status title

metadataobject (map)

Additional error metadata

Values

object
requestIdstring

Request identifier to include when contacting support

codestring

Stable machine-readable error code, when one applies

displayToUserboolean

True when detail is curated copy that is safe to show users

errorobject

The same error fields, for clients that only read body.error

detailstringrequired

Human-readable error message

statusnumberrequired

HTTP status code

titlestringrequired

HTTP status title

metadataobject (map)

Additional error metadata

Values

object
requestIdstring

Request identifier to include when contacting support

codestring

Stable machine-readable error code, when one applies

displayToUserboolean

True when detail is curated copy that is safe to show users