Create Resource

Method: POST /{api_prefix}/{collection_path}/ Auth: Flux API Keyalways required for writes, even on public APIs. The key's role must grant create on this API, and the target collection's connection must allow create (off by default).

Creates a resource with its first revision and publishes it immediately — the same pipeline as a Management API write: schema validation, a new revision, vectorization. This is the REST twin of the MCP create_record tool and shares its semantics exactly.


URL Pattern

POST https://{environment_key}.fxns.io/{api_prefix}/{collection_path}/

Nested collections use the path to carry their parents — the REST equivalent of the MCP parents argument:

  • POST https://7c9h4pwu.fxns.io/assistant/users/usr_8f2k1/memories/

Request Body

  • Name
    data
    Type
    object
    Required
    required
    Description

    The document body. Must match the collection schema — invalid documents return 422 with the standard content validation payload (errors[] with json_path).

  • Name
    key
    Type
    string
    Description

    Optional external identifier for deduplication. Creating a second resource with the same key in the collection returns 409 external_id_conflict instead of a duplicate.

No other top-level fields are accepted (422 otherwise). There is no draft mode: the caller cannot opt out of publishing or validation.


Response

201 Created:

{
  "resource_key": "kDLT9jjrcAzh",
  "revision_key": "r_2xW9",
  "write_units": 1,
  "published": true
}

write_units reports the weighted write charged for this call — max(1, ceil(embedded_tokens / 500)).


Example

curl -sS -X POST "https://7c9h4pwu.fxns.io/assistant/users/usr_8f2k1/memories/" \
  -H "Authorization: Simple <public_key>:<private_key>" \
  -H "Content-Type: application/json" \
  -d '{
        "data": {
          "content": "Prefers concise answers with code examples; time zone is CET.",
          "kind": "preference",
          "source": "chat-2026-07-22"
        },
        "key": "pref-communication"
      }'

Errors

Statuserror_codeWhen
401Missing/invalid credentials. Writes never accept anonymous callers, including on public APIs.
403access_deniedThe key's role lacks the create grant on this API.
403collection_not_writableThe collection's connection does not allow create. The body lists which collections do.
404Unknown collection path, or a nested parent that doesn't exist / isn't owned by the chain (strict reference).
405PATCH/DELETE are not supported on the Flux API. Updates are full replaces via PUT.
409external_id_conflictA resource with the supplied key already exists in this collection.
422content_validation_faileddata failed schema validation — body carries errors[] with json_path, capped at 100.
402spend_cap_reached / plan_exhaustedBilling block; machine-readable body.
502upstream_errorThe write pipeline failed or timed out. The outcome is unknown — verify with a GET before retrying; the API never retries writes automatically.

Failed calls are never billed.


Was this page helpful?