---
# @generated by sylphx-gen. Do not edit.
title: "Create a legal document"
description: "`auth.legal_documents.create` (POST /v1/{parent}/legal_documents): Creates an immutable draft revision."
type: reference
product: auth
summary: "Creates an immutable draft revision."
updated: 2026-09-28
nav: false
---

Creates an immutable draft revision.

- **Path** `POST https://api.sylphx.com/v1/orgs/acme/projects/shop/legal_documents`
- **Scope** `auth:write`
- **Effect** `write` — a successful call changes state.
- **Collection** [legal_documents](/docs/api/legal_documents)
- **Query** `legal_document_id`

## Request

| Field | Type | What it is |
| --- | --- | --- |
| `parent` | `string` | Canonical name of the parent Resource. Required. |
| `legal_document` | `LegalDocument` | Draft revision to create. Required. |
| `legal_document_id` | `string` | Optional legal document TypeID; Auth assigns one if omitted. |

### LegalDocument

| Field | Type | What it is |
| --- | --- | --- |
| `name` | `string` | Canonical Resource name. |
| `meta` | `ResourceMeta` | Resource metadata. |
| `spec` | `LegalDocumentSpec` | The immutable agreement text and publication policy. Required. |

### ResourceMeta

| Field | Type | What it is |
| --- | --- | --- |
| `labels` | `map<string, string>` | Caller-writable, indexed labels (AIP-122 label rules). |
| `annotations` | `map<string, string>` | Caller-writable, unindexed annotations. |
| `display_name` | `string` | Caller-writable human-readable name. |

### LegalDocumentSpec

| Field | Type | What it is |
| --- | --- | --- |
| `doc_slug` | `string` | A stable agreement kind, e.g. `terms`, `privacy`, `dpa`, `eula`. Required. |
| `version` | `string` | An opaque immutable version label, not used for ordering. Required. |
| `canonical_text` | `string` | Exact plain UTF-8 text shown to the user. Auth never normalizes it. Required. |
| `document_url` | `string` | An external HTTPS reference. Auth's canonical text, not this link, is evidence. Required. |
| `change_summary` | `string` | User-facing summary of the changes. Required. |
| `major_reconsent_required` | `bool` | Whether previously accepted versions become insufficient. |
| `effective_time` | `timestamp` | When a published revision takes effect. Required. |

## Response

| Field | Type | What it is |
| --- | --- | --- |
| `name` | `string` | Canonical Resource name. |
| `uid` | `string` | Server-assigned immutable ID. Output only. |
| `meta` | `ResourceMeta` | Resource metadata. |
| `spec` | `LegalDocumentSpec` | The immutable agreement text and publication policy. Required. |
| `status` | `LegalDocumentStatus` | Computed hash and publication state. Output only. |

### ResourceMeta

| Field | Type | What it is |
| --- | --- | --- |
| `generation` | `int64` | Increases by one on every change to `spec`. Output only. |
| `etag` | `string` | Strong ETag (AIP-154): changes on any change to spec, status, or metadata. Send it back as `If-Match` or `etag` to make Update and Delete conditional; a mismatch fails with ABORTED / 409 `ETAG_MISMATCH`. Output only. |
| `create_time` | `timestamp` | When the Resource was created. Output only. |
| `update_time` | `timestamp` | When the Resource last changed. Output only. |
| `delete_time` | `timestamp` | Set while the Resource is being deleted. Output only. |
| `labels` | `map<string, string>` | Caller-writable, indexed labels (AIP-122 label rules). |
| `annotations` | `map<string, string>` | Caller-writable, unindexed annotations. |
| `display_name` | `string` | Caller-writable human-readable name. |
| `creator` | `string` | The principal that created the Resource. Output only. |

### LegalDocumentSpec

| Field | Type | What it is |
| --- | --- | --- |
| `doc_slug` | `string` | A stable agreement kind, e.g. `terms`, `privacy`, `dpa`, `eula`. Required. |
| `version` | `string` | An opaque immutable version label, not used for ordering. Required. |
| `canonical_text` | `string` | Exact plain UTF-8 text shown to the user. Auth never normalizes it. Required. |
| `document_url` | `string` | An external HTTPS reference. Auth's canonical text, not this link, is evidence. Required. |
| `change_summary` | `string` | User-facing summary of the changes. Required. |
| `major_reconsent_required` | `bool` | Whether previously accepted versions become insufficient. |
| `effective_time` | `timestamp` | When a published revision takes effect. Required. |

### LegalDocumentStatus

| Field | Type | What it is |
| --- | --- | --- |
| `observed_generation` | `int64` | The spec generation observed by Auth. Output only. |
| `conditions` | `Condition[]` | Observed conditions. Output only. |
| `document_sha256` | `string` | Lowercase hex SHA-256 of the exact UTF-8 bytes of canonical_text. Output only. |
| `publish_time` | `timestamp` | Unset for drafts. No field can change after publication. Output only. |

### Condition

| Field | Type | What it is |
| --- | --- | --- |
| `type` | `string` | The condition type, for example `Ready`. |
| `status` | `ConditionStatus` | Whether the condition holds. One of `true`, `false`, `unknown`. |
| `observed_generation` | `int64` | The generation this observation was made against. |
| `reason` | `string` | A machine-readable UpperCamelCase reason. |
| `message` | `string` | A customer-safe human-readable message. |
| `severity` | `Severity` | How severe a FALSE condition is. One of `info`, `warning`, `error`. |
| `transition_time` | `timestamp` | When `status` last changed. |

## Errors

- [`UNAUTHENTICATED`](/docs/api/errors/UNAUTHENTICATED) — No valid key or token was presented.
- [`PERMISSION_DENIED`](/docs/api/errors/PERMISSION_DENIED) — The key lacks the method's permission.
- [`INVALID_FIELD`](/docs/api/errors/INVALID_FIELD) — A field failed validation.
- [`RESOURCE_ALREADY_EXISTS`](/docs/api/errors/RESOURCE_ALREADY_EXISTS) — A Resource with this name exists.
- [`IDEMPOTENCY_KEY_REUSED`](/docs/api/errors/IDEMPOTENCY_KEY_REUSED) — An Idempotency-Key was reused with another body.
- [`IDEMPOTENCY_IN_PROGRESS`](/docs/api/errors/IDEMPOTENCY_IN_PROGRESS) — The first call with this Idempotency-Key is still running.
- [`UNKNOWN_FIELD`](/docs/api/errors/UNKNOWN_FIELD) — The request has a field the schema does not know.

Every error arrives in the body [Errors](/docs/platform/errors) describes.

## Examples

**cURL**

```curl
curl -X POST "https://api.sylphx.com/v1/orgs/acme/projects/shop/legal_documents" \
  -H "Authorization: Bearer $SYLPHX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"spec":{"canonical_text":"…","change_summary":"…","doc_slug":"…","document_url":"…","effective_time":{},"version":"…"}}'
```

**TypeScript**

```ts
const response = await sylphx.auth.legalDocuments.create({ legalDocument: { spec: { canonicalText: '…', changeSummary: '…', docSlug: '…', documentUrl: '…', effectiveTime: {}, version: '…' } }, parent: 'orgs/acme/projects/shop' })
```

**Rust**

```rust
let mut req = sylphx::auth::CreateLegalDocumentRequest::default();
req.legal_document = Some(sylphx::auth::LegalDocument {
    spec: Some(sylphx::auth::LegalDocumentSpec {
        canonical_text: "…".to_string(),
        change_summary: "…".to_string(),
        doc_slug: "…".to_string(),
        document_url: "…".to_string(),
        effective_time: Some(Default::default()),
        version: "…".to_string(),
        ..Default::default()
    }),
    ..Default::default()
});
req.parent = "orgs/acme/projects/shop".to_string();
let response = sx.auth().legal_documents().create(req).await?;
```

**CLI**

```bash
sylphx auth legal-documents create --parent orgs/acme/projects/shop --spec.doc-slug … --spec.version … --spec.canonical-text … --spec.document-url … --spec.change-summary …
```

**MCP**

```json
{ "method_id": "auth.legal_documents.create", "args": {"legal_document":{"spec":{"canonical_text":"…","change_summary":"…","doc_slug":"…","document_url":"…","effective_time":{},"version":"…"}},"parent":"orgs/acme/projects/shop"} }
```
