# Authflows document

Source: https://www.pontive.com/docs/api-reference/management/authflows-document

Base URL: `https://api.{region}.pontive.com/v1` (operations that name another server say so).

Authentication: send `Authorization: Bearer <token>` with a secret key (`pontive_sk_…`, which implies its instance) or an access token issued for this API. A token that can reach several instances also names one with `X-Pontive-Instance-ID: inst_…`. Secret keys are for servers only.

## Export the authflows document

```http
GET https://api.{region}.pontive.com/v1/authn/authflows/document
```

The instance's auth flows as one authflows/v1 document (api-route-review D47): its published custom flows, each with its own widgets, and the custom widget definitions they show, so the document is self-contained. Only the published state is exported; drafts stay in the dashboard. Built-in flows and definitions are the same everywhere and never travel, and which app runs a flow is the app's authflow_bindings, not part of the flow. Everything is named by a key, never an id: a view node's widget is a definition's key or flow:<ref>, one of the flow's own widgets. authflow_id, repeatable, exports just those flows and the definitions they show (a flow that is not a published custom flow is 404); importing that document touches only them. The output is deterministic: two exports of the same state are byte-identical, and the ETag is the hash of the bytes. Send it as If-None-Match to get 304 when nothing changed. Import the document into another instance with POST /v1/authn/authflows/document/import. Needs sys:flow:read and sys:widget:read.

Operation ID: `GetAuthflowsDocument`

### Query parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `authflow_id` | string[] |  | Export only these flows, by id; repeat it for several |

### Responses

- `200` An authflows/v1 document: AuthflowsDocument
- `401` Unauthorized: ErrResponse
- `403` Forbidden: ErrResponse
- `404` An authflow_id that is not a published custom flow: ErrResponse
- `500` Internal Server Error: ErrResponse

## Import an authflows document

```http
POST https://api.{region}.pontive.com/v1/authn/authflows/document/import
```

Plans importing an authflows/v1 document into this instance and, with dry_run false, applies the plan (api-route-review D47). Flows and widget definitions are merged by key: a new key is created, a differing flow replaced whole, and one the document lacks is listed as absent and left alone. Nothing is deleted; delete a flow with DELETE /v1/authn/authflows/{authflow_id}. A definition the instance lacks is created and published; identical markup is unchanged, and different markup is a conflict, since a published definition never changes. A changed flow keeps each of its own widgets whose content matches, and gets a new one where content changed. With publish true (the default) each changed flow is published, its widgets first; with publish false it writes drafts for review in the dashboard. Anything the flow's publish validator refuses, a reference to a key in neither the document nor the instance, and a draft with unpublished changes the import would overwrite (unless discard_unpublished) are conflicts. Re-importing an instance's own export plans every entry unchanged and writes nothing. The dry run's ETag is the revision of the flows it read: send it as If-Match on the apply to be refused 412 precondition_failed if anything changed since. An apply with conflicts is 409 import_conflict, one detail per conflict, field <kind>.<key>.<field>, and applies nothing. A document the format refuses (not JSON, a member it does not define, a pontive_document it does not read) is 422 field_invalid_format; one over 5 MB is 422 field_too_long. X-Idempotency-Key makes an apply safe to retry; the same key with another request is 422 idempotency_key_reused. Needs sys:flow:manage, sys:widget:read and sys:widget:manage.

Operation ID: `ImportAuthflowsDocument`

### Header parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `If-Match` | string |  | The dry run's ETag: the apply is refused 412 precondition_failed if the instance's flows changed since |
| `X-Idempotency-Key` | string |  | Idempotency key, read on an apply |

### Request body (`application/json`, required): ImportAuthflowsRequest

The document and how to import it

### Responses

- `200` OK: AuthflowImportPlan
- `400` Bad Request: ErrResponse
- `401` Unauthorized: ErrResponse
- `403` Forbidden: ErrResponse
- `409` import_conflict: the plan has conflicts, one detail each; nothing was applied: ErrResponse
- `412` precondition_failed: the flows changed since the dry run: ErrResponse
- `422` field_invalid_format, field_too_long, missing_required_field or idempotency_key_reused: ErrResponse
- `500` Internal Server Error: ErrResponse

## Schemas

### AuthflowsDocument

Document is an authflows/v1 document, passed to identity-svc as the
bytes it was sent. At most 5 MB.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `authflows` | AuthflowsDocumentFlow[] |  |  |
| `pontive_document` | "authflows/v1" |  | PontiveDocument is the document type. An import reads the current and the previous major version. |
| `pontkit` | string |  | Pontkit is the pontkit release the document was exported against. Informational: an import checks markup against the target's release. |
| `widget_definitions` | DocumentWidgetDefinition[] |  | WidgetDefinitions are the instance's own definitions the flows show, never a built-in. A published definition never changes, so this copy is the branding document's: a key the target lacks is created and published, identical markup is unchanged, other markup is a conflict. |

### ErrResponse

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `error` | ErrBody |  |  |

### ImportAuthflowsRequest

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `discard_unpublished` | boolean |  | DiscardUnpublished lets the import overwrite a draft with unpublished changes, which is otherwise a conflict. |
| `document` | AuthflowsDocument |  | Document is an authflows/v1 document, passed to identity-svc as the bytes it was sent. At most 5 MB. |
| `dry_run` | boolean |  | DryRun returns the plan and writes nothing. True when omitted: send false to apply. |
| `publish` | boolean |  | Publish publishes what the import changes. True when omitted; false writes drafts for review in the dashboard. |
| `secrets` | Record<string, string> |  | Secrets are the values of the document's {"$secret": "<name>"} placeholders, by name; never inside the document, and never echoed back. A placeholder with no value here or in the target is a conflict. |

### AuthflowImportPlan

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `absent` | PlanEntry[] |  |  |
| `changed` | PlanEntry[] |  |  |
| `conflicts` | PlanIssue[] |  |  |
| `created` | PlanEntry[] |  |  |
| `dry_run` | boolean |  | DryRun is true when nothing was written. |
| `object` | "authflow_import_plan" |  |  |
| `publish` | boolean |  | Publish says whether the changed flows are published, or left as drafts. New widget definitions are published either way. |
| `unchanged` | PlanEntry[] |  |  |
| `warnings` | PlanIssue[] |  |  |

### AuthflowsDocumentFlow

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `description` | string |  |  |
| `edges` | Edge[] |  |  |
| `entry_node` | string |  |  |
| `id` | string |  |  |
| `intents` | "signin" \| "signup" \| "invitation"[] |  |  |
| `metadata` | DocumentMetadata |  |  |
| `name` | string |  |  |
| `nodes` | Node[] |  |  |
| `role` | "entry" \| "subflow" |  |  |
| `widgets` | Record<string, AuthflowsDocumentFlowWidget> |  | Widgets are the flow's own widgets by ref: the widget's key, suffixed -2, -3 in node order when the flow owns several copies of one definition. |

### DocumentWidgetDefinition

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `description` | string |  |  |
| `key` | string |  |  |
| `markup` | string |  | Markup is the definition's pontkit markup. |
| `name` | string |  |  |

### ErrBody

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `code` | string |  | Code is the spec's machine-readable code for this error, in snake case: a domain code such as seat_limit_reached where the refusal has one, otherwise a generic one such as permission_denied, not_found, conflict, invalid_request or service_unavailable. |
| `details` | ErrDetail[] |  | Details are per-field findings, present only on a refusal that has them, e.g. a 422 invalid_theme names each invalid value by its path, a 422 package_invalid each problem, and a 409 capability_in_use each count by its name. |
| `doc_url` | string |  | DocURL links to documentation about this error, when available. |
| `message` | string |  | Message is a human-readable description of what went wrong. |
| `object` | string |  | Object is the discriminator; always "error". |
| `param` | string |  | Param names the request parameter this error refers to, when applicable. |
| `type` | "validation_error" \| "authentication_error" \| "authorization_error" \| "not_found" \| "conflict_error" \| "rate_limit_error" \| "internal_error" |  | Type is the error's category, set by its HTTP status: one of validation_error, authentication_error, authorization_error, not_found, conflict_error, rate_limit_error, internal_error. |

### PlanEntry

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `fields` | string[] |  | Fields are the document fields that differ, for a changed object. |
| `key` | string |  | Key is the object's key in the document: a flow's or a blueprint's id, a definition's key, a customization's widget_key, an asset's sha256-<hex>, or "" for a singleton (brand, theme, localization). |
| `kind` | string |  | Kind is what the object is. |

### PlanIssue

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `code` | string |  | Code says why. A conflict's: invalid, immutable, retired, missing_reference, unpublished_changes, missing_secret or assets_not_available. A warning's: instance_specific_id, unknown_connection, locale_not_enabled, unused_asset, unused_secret or validation. |
| `field` | string |  | Field is the document field it is about, "" for the whole object. The whole path is <kind>.<key>.<field>, the field a 409 import_conflict detail names. |
| `key` | string |  |  |
| `kind` | string |  |  |
| `message` | string |  |  |

### Edge

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `from` | string |  |  |
| `id` | string |  |  |
| `to` | string |  |  |
| `trigger` | Trigger |  |  |

### DocumentMetadata

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `viewport` | Viewport |  |  |

### Node

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `action_type` | string |  | ActionType is the catalog action id on an action node. |
| `expression` | string |  | Expression is the condition node's branch expression. |
| `flow_id` | string |  | FlowID is the flow a subflow node delegates to. |
| `id` | string |  |  |
| `kind` | "start" \| "end" \| "view" \| "action" \| "condition" \| "subflow" |  |  |
| `metadata` | NodeMetadata |  |  |
| `name` | string |  |  |
| `outcome` | string |  | Outcome is set on an end node: the outcome the flow ends with, a slug (lower-case letters, digits and underscores), "succeeded" when absent. A flow's outcomes are the distinct values on its end nodes; a parent's subflow node routes them by name. |
| `properties` | Record<string, any> |  | Properties is the action configuration. An action node names no widget: one that waits for the user shows its own screens (pontive-spec 23). |
| `widget` | string |  | Widget is the view node's widget id — a built-in widget's or a custom widget's. |
| `widget_overrides` | Record<string, string> |  | WidgetOverrides, on a subflow node, replaces widgets inside the flow it enters and below it: key is the KEY of the widgets replaced — the definition they descend from — value the id of the widget shown instead. At most 16 entries; absent when there are none (pontive-spec 16a, 22). |

### AuthflowsDocumentFlowWidget

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `key` | string |  |  |
| `markup` | string |  |  |
| `name` | string |  |  |

### ErrDetail

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `field` | string |  | Field is where the finding is: for a theme, its dotted path. |
| `message` | string |  | Message is what is wrong there. |

### Trigger

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `event` | string |  |  |
| `kind` | "user-event" \| "outcome" \| "auto" |  |  |
| `outcome` | string |  |  |

### Viewport

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `x` | number |  |  |
| `y` | number |  |  |
| `zoom` | number |  |  |

### NodeMetadata

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `note` | string |  |  |
| `position` | NodePosition |  |  |

### NodePosition

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `x` | number |  |  |
| `y` | number |  |  |
