> ## Documentation Index
> Fetch the complete documentation index at: https://dev.chief.bot/llms.txt
> Use this file to discover all available pages before exploring further.

# Create Project Invitation

> Invites one user to the project by email. The invitation email is
sent automatically. The invited user becomes a project member only
after accepting — until then they cannot be added to a restricted
chat's audience.

Each project holds at most one invitation per role. When one
already exists for the requested role, the email is added to it and
that invitation is returned; inviting an email that is already on
it succeeds with the current state. `409` with code
`publicapi.projects.invitations.create.role.exists` occurs only
when a concurrent request creates the role's invitation mid-flight
— retrying adds the email to it.




## OpenAPI

````yaml /openapi.yaml post /v1/projects/{id}/invitations
openapi: 3.0.3
info:
  title: Chief Public API
  version: 1.0.0
  contact:
    name: Chief Support
    url: https://chief.bot
  description: |
    Chief's public REST API for programmatic access to chats and assets.

    All endpoints are authenticated with a Personal Access Token (PAT)
    sent in the `X-API-Key` header. PATs are minted out-of-band from the
    Chief settings UI.

    All endpoints that touch project-scoped resources require the
    `X-Project-Id` header. Missing or invalid project IDs respond with HTTP
    400 and the error code `publicapi.tenancy.project.missing`.

    ## Error envelope

    Every error response uses the same JSON envelope:

    ```json
    { "code": "publicapi.auth.invalid",
      "humane": "The provided API key is invalid or has been revoked.",
      "statusCode": 401 }
    ```

    `code` is a stable, dotted, lowercase identifier suitable for client-side
    i18n and analytics. `humane` is plain English safe to surface to end
    users. `statusCode` mirrors the HTTP status.

    ## Chat workflow — kickoff + poll

    Chats are asynchronous in v1. Callers need to poll the
    per-message endpoint until the content they need is present.

    1. `POST /v1/chats` with `{prompt}`. The server kicks off the
       workflow and returns `{chat_id, message_id, created_at}`
       immediately. `message_id` is the message you'll poll.
    2. `POST /v1/chats/{chat_id}/messages` with `{prompt}` to
       continue an existing chat — appends a new turn and returns
       `{message_id, created_at}`.
    3. `GET /v1/chats/{chat_id}/messages/{message_id}` to read the
       message. While the workflow is still writing, `prompt` and
       `response` are omitted; once written they're present. Treat the
       appearance of `response` as the signal that the assistant has
       produced output.
    4. `GET /v1/chats/{chat_id}` returns chat-level metadata only
       (`modified_at`). It does not carry messages.
    5. `GET /v1/chats/{chat_id}/messages` lists every message's id +
       `created_at` (no content); clients fetch one message at a time via
       `GET /v1/chats/{chat_id}/messages/{mid}` for the prompt + response
       body.

    ## Asset workflow — three-step upload

    Assets are uploaded directly to blob storage via a signed URL. The flow
    is:

    1. `POST /v1/assets` with `{filename, mime_type}`, optionally including
       the hex-encoded `md5` of the file. When `md5` matches content already
       in the project the server returns `200` with `already_exists: true` and
       no upload URL — skip to fetching the asset. Otherwise it returns `201`
       with `{asset_id, upload_url, upload_method:"PUT", upload_headers,
       expires_at}`.
    2. `PUT` the file bytes to `upload_url`, applying every header in
       `upload_headers` verbatim. The URL is valid until `expires_at`.
    3. `POST /v1/assets/{asset_id}/complete` with an empty body to
       hand the asset off to the ingest pipeline. The server reads the
       uploaded object's size and MD5 from blob storage at this step. The
       response carries the current `AssetResponse`; clients poll until
       `status` is `ready` or `failed`.
servers:
  - url: '{baseUrl}'
    description: Chief
    variables:
      baseUrl:
        default: https://api.storytell.ai
        description: Base URL of the deployment serving the API.
security:
  - apiKey: []
tags:
  - name: Chats
    description: Public chat lifecycle — kickoff, list, fetch.
  - name: Assets
    description: Public asset upload + ingest lifecycle.
  - name: Labels
    description: Public label CRUD and asset-label attachment.
  - name: Actions
    description: Public action CRUD plus enable/disable.
  - name: Sessions
    description: Public recording-session listing and CRUD.
  - name: Skills
    description: Public skill CRUD plus enable/disable.
  - name: Memories
    description: Public memory CRUD.
  - name: Projects
    description: Public project create/edit, membership, and invitations.
paths:
  /v1/projects/{id}/invitations:
    post:
      tags:
        - Projects
      summary: Create Project Invitation
      description: |
        Invites one user to the project by email. The invitation email is
        sent automatically. The invited user becomes a project member only
        after accepting — until then they cannot be added to a restricted
        chat's audience.

        Each project holds at most one invitation per role. When one
        already exists for the requested role, the email is added to it and
        that invitation is returned; inviting an email that is already on
        it succeeds with the current state. `409` with code
        `publicapi.projects.invitations.create.role.exists` occurs only
        when a concurrent request creates the role's invitation mid-flight
        — retrying adds the email to it.
      operationId: createProjectInvitation
      parameters:
        - $ref: '#/components/parameters/ProjectIdPath'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateProjectInvitationRequest'
            example:
              email: alice@example.com
              role: collaborator
      responses:
        '201':
          description: >
            Invitation created, or the email was added to the role's existing
            invitation. The invitation email is sent to newly added addresses.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProjectInvitationResponse'
              example:
                invitation_id: boundary_d8aad64dib2c7m3ae7j0
                email: alice@example.com
                role: collaborator
                url: https://auth.storytell.ai/roles/collaborator/inv_tok_3xa…
                created_at: '2026-05-01T12:00:00Z'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '500':
          $ref: '#/components/responses/InternalServerError'
      security:
        - apiKey: []
components:
  parameters:
    ProjectIdPath:
      in: path
      name: id
      required: true
      schema:
        type: string
        pattern: ^project_[a-z0-9]{20}$
      example: project_d8a4td4dib27i4beefb0
      description: |
        Project identifier in the path. Project routes carry no tenancy
        header; ids outside the caller's reach respond with HTTP 404.
  schemas:
    CreateProjectInvitationRequest:
      type: object
      required:
        - email
        - role
      properties:
        email:
          type: string
          format: email
        role:
          type: string
          enum:
            - collaborator
            - reader
            - owner
          description: |
            Role granted on acceptance. Validated before anything is
            persisted; unknown values respond with code
            `publicapi.projects.invitations.create.role.invalid`.
    ProjectInvitationResponse:
      type: object
      required:
        - invitation_id
        - email
        - role
        - url
        - created_at
      properties:
        invitation_id:
          type: string
          pattern: ^boundary_[a-z0-9]{20}$
        email:
          type: string
          format: email
        role:
          type: string
          enum:
            - collaborator
            - reader
            - owner
          description: Short public role name, echoing the request.
        url:
          type: string
          format: uri
          description: |
            Shareable accept link — the same one sent in the invitation
            email.
        created_at:
          type: string
          format: date-time
    Error:
      type: object
      required:
        - code
        - statusCode
      properties:
        code:
          type: string
          pattern: ^[a-z][a-z0-9_]*(\.[a-z0-9_]+)+$
          description: |
            Stable dotted, lowercase identifier, namespaced by domain and
            operation (`<domain>.<op>.<reason>`). Suitable for client-side
            i18n keys and analytics. Codes are additive; existing codes are
            never reworded.
          example: publicapi.auth.invalid
        humane:
          type: string
          description: Plain-English message safe to display to end users.
          example: The provided API key is invalid or has been revoked.
        statusCode:
          type: integer
          minimum: 400
          maximum: 599
          description: |
            Mirror of the HTTP status code. (Field name is camelCase here
            only — owned by `nutils.Error` across the platform.)
          example: 401
  responses:
    BadRequest:
      description: Malformed request, validation failure, or missing tenancy header.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          examples:
            missingProject:
              summary: Missing X-Project-Id
              value:
                code: publicapi.tenancy.project.missing
                humane: X-Project-Id header is required.
                statusCode: 400
    Unauthorized:
      description: Missing, malformed, or revoked credentials.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            code: publicapi.auth.invalid
            humane: The provided API key is invalid or has been revoked.
            statusCode: 401
    NotFound:
      description: Resource does not exist or is outside the caller's reach.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Conflict:
      description: The resource is in a state that rejects this operation.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            code: publicapi.chats.members.add.not_restricted
            humane: Set chat visibility to restricted before managing members.
            statusCode: 409
    InternalServerError:
      description: Unexpected server error.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    apiKey:
      type: apiKey
      in: header
      name: X-API-Key
      description: |
        Personal Access Token, sent verbatim as `pat_<32 chars>`. PATs are
        minted from the Chief settings UI.

````