Skip to content

[Feature Request] Side-Posting in automatic REST API #2373

@lsmith77

Description

@lsmith77

Is your feature request related to a problem? Please describe.
Currently, ZenStack's automatic REST API handles single-resource creation effectively. However, when building complex frontends (especially those using JSON:API standards), there is often a need to create a primary entity along with several related "child" entities in a single atomic HTTP request.

Without support for Local IDs (lid) and the included section for writable operations, developers must:

  1. Issue multiple sequential requests.
  2. Manage temporary client-side IDs.
  3. Handle partial failures (where the parent is created but children fail), which complicates transaction management on the frontend.

Describe the solution you'd like
I would like the ZenStack REST API to support "side-posting" by recognizing the lid (Local ID) and included attributes during a POST request. This would allow a single request to create a resource and its related resources simultaneously by linking them via a temporary local identifier.

Key Requirements:

  • LID Support: Support lid as a temporary identifier within the relationships and included blocks to link resources that don't have a server-generated ID yet.
  • Side-posting in included: The API should parse the included array in a POST request and treat those objects as resources to be created alongside the primary data.
  • Atomic Operations (Next Step): Ideally, this should pave the way for full support of the JSON:API Atomic Operations extension, allowing multiple independent operations in one transaction.

Example Payload:

{
  "data": {
    "type": "articles",
    "attributes": { "title": "New Article" },
    "relationships": {
      "author": { "data": { "type": "people", "lid": "temp-author-1" } }
    }
  },
  "included": [
    {
      "type": "people",
      "lid": "temp-author-1",
      "attributes": { "name": "Jane Doe" }
    }
  ]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions