Skip to content

Require a second factor at sign-in

View as Markdown
PATCH
/v1/auth/settings
curl --request PATCH \
--url https://example.com/v1/auth/settings \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "secondFactor": { "required": true } }'

Covers signing in by the deployment’s own ways in (the emailed link, and providers like Google, Microsoft and GitHub). Signing in through the workspace’s own identity provider is exempt: it owns MFA there. A site’s people sign in through the site, which owns their second factor, so the setting doesn’t apply to them. Once required, a session made without a second factor ends at its next request, and signing in to the console with an API token is refused. API keys aren’t covered: keep them to service accounts, and rotate them. From a session, turning it on takes a session made with your own second factor (409 second-factor-enroll-first): it would end yours. Audited. Tenant admins only. Mounted when the deployment keeps second factors (from 0.1.9).

Idempotency-Key
string
>= 1 characters

Caller-supplied idempotency key, scoped to the caller: the same key from someone else in the tenant is their own request (from 0.1.5). Retries with the same key return the original response byte-identical (per docs/API-ROUTE-CONVENTIONS.md §3.1). A retry sent while the first request still runs is answered 409 idempotency-key-in-flight with Retry-After, on a runtime whose store holds keys (from 0.1.5); retry after it, and you get the first request’s answer. An answer that carries a secret (a new API key or public run token, a session token, a generated signing secret) isn’t kept: a retry gets 409 idempotency-key-replay-withheld, with the first request’s status and when it succeeded (from 0.1.5).

Media typeapplication/json

Require a second factor at sign-in, or stop requiring one.

object
secondFactor
required
object
required
required
boolean
Examplegenerated
{
"secondFactor": {
"required": true
}
}

The settings, after.

Media typeapplication/json

The workspace’s sign-in settings.

object
secondFactor
required
object
required
required

Signing in by the deployment’s own ways in takes a second factor. Signing in through the workspace’s own identity provider is exempt: it owns MFA there. A site’s people sign in through the site, which owns their second factor, so the setting doesn’t apply to them. API keys aren’t covered.

boolean
onPreviousSecret
required

People whose key is still kept under the deployment’s previous sign-in secret: each moves to the current one at their next code. Keep the previous secret configured until this is 0.

integer
unusable
required

People whose key opens under neither secret: they need a recovery code, or an admin to remove it.

integer
Examplegenerated
{
"secondFactor": {
"required": true,
"onPreviousSecret": 1,
"unusable": 1
}
}

Malformed request body.

Media typeapplication/json
object
error
required
object
code
required

Stable machine-readable discriminant. Values match domain error codes (see docs/API-ROUTE-CONVENTIONS.md §4.3).

string
message
required
string
details

Optional, kind-specific.

object
key
additional properties
any
requestId
required

Server-assigned request id; also echoed via X-Request-Id header.

string
Examplegenerated
{
"error": {
"code": "example",
"message": "example",
"details": {},
"requestId": "example"
}
}

Missing / malformed / expired / revoked bearer token.

Media typeapplication/json
object
error
required
object
code
required

Stable machine-readable discriminant. Values match domain error codes (see docs/API-ROUTE-CONVENTIONS.md §4.3).

string
message
required
string
details

Optional, kind-specific.

object
key
additional properties
any
requestId
required

Server-assigned request id; also echoed via X-Request-Id header.

string
Examplegenerated
{
"error": {
"code": "example",
"message": "example",
"details": {},
"requestId": "example"
}
}

Not a tenant admin.

Media typeapplication/json
object
error
required
object
code
required

Stable machine-readable discriminant. Values match domain error codes (see docs/API-ROUTE-CONVENTIONS.md §4.3).

string
message
required
string
details

Optional, kind-specific.

object
key
additional properties
any
requestId
required

Server-assigned request id; also echoed via X-Request-Id header.

string
Examplegenerated
{
"error": {
"code": "example",
"message": "example",
"details": {},
"requestId": "example"
}
}

Turned on from a session made without a second factor (second-factor-enroll-first), or an idempotency conflict.

Media typeapplication/json
object
error
required
object
code
required

Stable machine-readable discriminant. Values match domain error codes (see docs/API-ROUTE-CONVENTIONS.md §4.3).

string
message
required
string
details

Optional, kind-specific.

object
key
additional properties
any
requestId
required

Server-assigned request id; also echoed via X-Request-Id header.

string
Examplegenerated
{
"error": {
"code": "example",
"message": "example",
"details": {},
"requestId": "example"
}
}

The request body is over the API’s limit (request-too-large; details.maxBytes says how much).

Media typeapplication/json
object
error
required
object
code
required

Stable machine-readable discriminant. Values match domain error codes (see docs/API-ROUTE-CONVENTIONS.md §4.3).

string
message
required
string
details

Optional, kind-specific.

object
key
additional properties
any
requestId
required

Server-assigned request id; also echoed via X-Request-Id header.

string
Examplegenerated
{
"error": {
"code": "example",
"message": "example",
"details": {},
"requestId": "example"
}
}

Server error (unmapped domain code or framework crash).

Media typeapplication/json
object
error
required
object
code
required

Stable machine-readable discriminant. Values match domain error codes (see docs/API-ROUTE-CONVENTIONS.md §4.3).

string
message
required
string
details

Optional, kind-specific.

object
key
additional properties
any
requestId
required

Server-assigned request id; also echoed via X-Request-Id header.

string
Examplegenerated
{
"error": {
"code": "example",
"message": "example",
"details": {},
"requestId": "example"
}
}

See also