# Conversation Records API

Aideify turns conversation messages into typed records with source quotations and editable proposals. Your application supplies a versioned schema and sends conversation turns. It receives field changes, review states and a durable revision. Conversation delivery and the user interface remain in your application.

## Account access

Sign in at [API console](/api/console/) and create a key with **Conversation records** access. Choose read/write for schema registration, turns, reviews and deletion, or read-only for inspection. The existing one-credit API activation applies once per account; key replacements are free. Existing Form Filler keys do not grant record access.

An integration can instead `POST /api/v1/records/authorizations` with `{"name":"My integration","scope":"records:write"}`. Show the returned `authorizationUrl` to the account owner. After they approve, poll the returned `tokenUrl` with `{"secret":"<returned secret>"}`, no more often than the returned interval. This uses Aideify's shared account authorization endpoints. Never log the secret or returned key. Approval does not grant turn allowance or authorize an automatic payment.

## Usage allowance

`GET /api/v1/records/usage` reports granted, used and remaining **user-turn starts**. The initial grant is zero. Aideify must grant a conversation-record allowance before user extraction starts. This API takes no automatic payment. A failed or interrupted user-turn start consumes one allowance unit; an identical idempotent retry does not consume another or repeat inference. Schema operations, reads, reviews, context-only turns and deletion do not consume user-turn allowance. Optional composition is included within a user-turn start and uses the existing bounded processing policy. Allowance usage is separate from Form Filler completion credits.

## Schema and session

Use `Authorization: Bearer <customer key>` for every product operation below. Keep keys on your server.

1. `POST /api/v1/records/schemas` with an immutable `{id,version,fields}`. Each field has `key`, `description`, `type` (`string` or `chapters`), `kind` (`extracted` or `composed`) and `maxLength`. Chapter values are arrays of `{place,period,detail}` strings. Composed fields also declare `fromFields`, use only reviewed supported inputs, have a maximum length of 2,000 and produce unapproved drafts. They cannot depend on other composed fields. Unchanged schema registration is repeatable; changed schemas require a new version.
2. `POST /api/v1/records/sessions` with `{id,schema,version}`. Choose a stable opaque session id for one of your users. Repeating the same id and schema resumes that record. Customer keys isolate schemas and sessions from other accounts.
3. `POST /api/v1/records/sessions/{id}/turns` with `{expectedRevision,turn:{id,role,text},compose:false}`. Set `Idempotency-Key` equal to `turn.id`. User text supplies evidence; assistant and system messages supply context only. `compose:true` opts into suggested wording from reviewed inputs. `allowRemote:false` prohibits external processing for that turn.
4. `GET /api/v1/records/sessions/{id}` reads answers, current revision and processing status. Answer states are `supported`, `check` or `missing`. Quoted evidence identifies user source turns; it does not prove the proposed interpretation is correct. Generated wording is a separate unapproved draft, never extracted evidence.
5. `PATCH /api/v1/records/sessions/{id}/answers/{field}` with `{expectedRevision,action,value?}` and a unique `Idempotency-Key`. Actions are `edit`, `approve`, `omit` or `accept` a pending revision. Human wording, approved answers and intentionally cleared values remain protected from automatic replacement.

Example schema:

```json
{
  "id": "person",
  "version": 1,
  "fields": [
    {
      "key": "name",
      "required": true,
      "description": "The person's self-stated name",
      "type": "string",
      "kind": "extracted",
      "maxLength": 100
    },
    {
      "key": "places",
      "description": "Places the person lived; retain vague periods without inventing dates",
      "type": "chapters",
      "kind": "extracted",
      "maxLength": 3000
    }
  ]
}
```

Example turn:

```json
{
  "expectedRevision": 0,
  "turn": {
    "id": "turn-1",
    "role": "user",
    "text": "I'm Alex. I grew up in Boston and now I'm nomadic."
  }
}
```

## Required fields and completion

Set `required: false` on optional schema fields. Fields default to required when the flag is omitted; existing immutable schemas are unchanged. To change which fields are required, register a new schema version. Existing sessions keep their pinned version.

Every session creation, read, turn and review response includes one `completion.percent`: `Math.round(100 * answeredRequired / totalRequired)`. A form with zero required fields is 100%. A valid nonempty answer counts even while it awaits review; whitespace, empty chapter arrays, cleared answers and pending replacements for a cleared value do not count. Approval remains separate from answered-data completion, and 100% does not submit, publish or provision anything.

`completion` also returns `totalRequired`, `answeredRequired`, `missingRequired`, `optional`, `missingOptional` and `unknownRequired` (empty for record schemas). Existing `missing` and `check` lists remain available across required and optional fields. Uploading a source alone does not answer fields. Completion is derived from the saved answer revision, never estimated by a model.

## Revisions, retries and errors

Only one mutation can process a session at a time. A concurrent turn, review or deletion receives 409; read the record and retry after processing finishes. Stale revisions receive 409 without replacing data. A reused idempotency key with different input receives 409. Invalid input receives 422, missing/revoked keys 401, wrong scope 403 and exhausted allowance 429. Errors include `error`, `code` and `requestId`.

A turn response with `availability: unavailable` preserves existing answers and stores the user turn without pretending extraction succeeded. An interrupted reservation becomes indeterminate after 90 seconds; the same operation never auto-replays. Read the record before choosing a new turn id. This prevents automatic duplicate provider execution but does not promise exactly-once execution after network failure.

## Inspection, retention and limits

`GET /sessions/{id}/sources` returns user evidence text; `GET /sessions/{id}/history` returns field revision history, under the same `/api/v1/records` prefix. `DELETE /sessions/{id}` removes the active session's source text, answers, history and content-bearing idempotency receipts. Aggregate allowance usage remains and is not reset by deletion. `DELETE /schemas/{id}/versions/{version}` removes an unused schema version after its sessions are deleted. Record content remains until deletion; see [Data & privacy](/privacy/) for the service's broader processing terms.

Limits are 100 schema versions and 100 active sessions per customer, 30 fields per schema, 200 turns per session, 4,000 characters per turn and 2 MiB per persisted record. Chapter arrays allow up to 30 entries; place/period are at most 200 characters and detail at most 2,000. Key/account rate limits are 120/240 requests per minute. Storage or processing limits return explicit errors and preserve the previous record.

[OpenAPI contract](/api/v1/records/openapi.json) · [My account](/api/console/) · [Developer APIs](/developers/)


## Source artifacts

Upload original writing samples, life documents or photographs to an owned record session without creating a target form. Use the same server-side records:write key. Source uploads do not automatically change or approve profile facts.

`POST /api/v1/records/sessions/{id}/artifacts` accepts multipart `file`, `expectedRevision`, `kind` (photo, writing, document), `subject` (subject, other, unknown), `authorship` (subject, other, unknown), optional `caption` (1,000 characters) and `period` (200 characters). Set a unique `Idempotency-Key`; it becomes the source ID. The response includes the artifact, attributed metadata, source text with locators, extraction status and the new record revision. Identical retries return the stored result; stale/busy/indeterminate requests follow the record mutation rules above.

PDF (at most 20 pages), DOCX, UTF-8 TXT and Markdown use Aideify's source readers with remote processing disabled. Incomplete reading is flagged for review, and unreadable files receive an explicit error. Photos in JPEG, PNG or WebP are stored privately; the client supplies its image-interpretation workflow. Source-only reading performs no semantic rewriting, consumes no form completion credits or user-turn allowance, and makes no remote model request.

`GET /sessions/{id}/artifacts` lists owned sources. `GET /sessions/{id}/artifacts/{sourceId}` reads metadata and extracted text. `GET /sessions/{id}/artifacts/{sourceId}/file` downloads the original as an authenticated attachment. These paths use the same `/api/v1/records` prefix; original files have no public download URL. `DELETE /sessions/{id}/artifacts/{sourceId}` takes JSON `{expectedRevision}` and a fresh Idempotency-Key, deleting the original, extracted text and content-bearing upload receipt. Session deletion removes all its artifacts. Client-created interpretations or derived profile fields remain the client's responsibility.

Limits: 3 MiB per file, 10 artifacts and 20 MiB original bytes per session, 60 MiB per customer, and 100,000 extracted text characters per upload. Remove sources before exceeding the storage limits. Writing attribution distinguishes the subject's own words from material written by someone else.
