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

# Register an AWS delegated grant

> Registers the AWS delegated-grant coordinates for an AWS-sink subscription (`sqs`, `eventbridge`) — the non-secret cross-account delivery role ARN, region, and destination the dispatcher assumes at delivery time. This is the write that follows the customer applying the setup-artifacts trust policy in their AWS account. It is write-only: it runs no inline probe and does not change the verification state (a registered grant stays `pending_verification` until a later `verify`). No AWS credential crosses this body. The destination host is validated before the write. A non-AWS sink returns `422 validation_error`.



## OpenAPI

````yaml en/openapi/v3-current/streaming-hub.yaml put /v1/subscriptions/{id}/delegated-grant
openapi: 3.1.0
info:
  title: Lerian Streaming Hub API
  version: v1.0.0
  contact:
    email: contact@lerian.studio
    name: Lerian Studio
    url: https://lerian.studio
  license:
    name: Lerian Studio General License
  description: >-
    The Streaming Hub control-plane API. Streaming Hub is Lerian's managed
    event-delivery edge: it consumes CloudEvents from the platform's internal
    streaming backbone and fans them out to a tenant's own external destinations
    — webhooks, Amazon SQS, RabbitMQ, Amazon EventBridge, or a pull inbox. This
    API lets a tenant browse the manifest-fed event catalog, create and manage
    delivery subscriptions, verify and rotate their credentials, read delivery
    health, and pull entitled events.


    Errors use a flat `{"error":"<token>"}` envelope (a low-cardinality,
    machine-readable token — never RFC 9457 problem+json). Mutating operations
    require an `X-Idempotency` header for at-most-once semantics; a replayed
    request returns the original response byte-for-byte with
    `X-Idempotency-Replayed: true`. The catalog and the pull events surface are
    tenant-scoped through the bearer JWT; the operational probe endpoints
    (`/healthz`, `/readyz`, `/version`, `/runtime`, `/metrics`) are
    unauthenticated. Streaming Hub is closed source under the Lerian Studio
    General License.
servers:
  - url: https://streaming-hub.sandbox.lerian.net
security:
  - BearerAuth: []
tags:
  - name: Catalog
    description: Browse the manifest-fed catalog of event types available for subscription.
  - name: Subscriptions
    description: >-
      Create, read, update, and delete delivery subscriptions, and drive the
      destination verification lifecycle (ping, verify, credential, delegated
      grant, secret rotation, health).
  - name: Event Delivery
    description: >-
      Pull entitled events for a pull-sink subscription
      (cursor-as-acknowledgment read).
  - name: Admin
    description: Cross-tenant operator forensics. Requires an operator authorization scope.
  - name: Operational
    description: Unauthenticated liveness, readiness, build, runtime, and metrics probes.
paths:
  /v1/subscriptions/{id}/delegated-grant:
    put:
      tags:
        - Subscriptions
      summary: Register an AWS delegated grant
      description: >-
        Registers the AWS delegated-grant coordinates for an AWS-sink
        subscription (`sqs`, `eventbridge`) — the non-secret cross-account
        delivery role ARN, region, and destination the dispatcher assumes at
        delivery time. This is the write that follows the customer applying the
        setup-artifacts trust policy in their AWS account. It is write-only: it
        runs no inline probe and does not change the verification state (a
        registered grant stays `pending_verification` until a later `verify`).
        No AWS credential crosses this body. The destination host is validated
        before the write. A non-AWS sink returns `422 validation_error`.
      operationId: putSubscriptionDelegatedGrant
      parameters:
        - $ref: '#/components/parameters/SubscriptionId'
        - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DelegatedGrantRequest'
      responses:
        '200':
          description: >-
            The grant was persisted (no body; the verification state is
            unchanged).
          headers:
            X-Idempotency-Replayed:
              $ref: '#/components/headers/IdempotencyReplayed'
        '400':
          $ref: '#/components/responses/BadRequestOrMissingIdempotency'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/IdempotencyConflict'
        '422':
          description: >-
            The request is caller-correctable. `error` is `validation_error` (a
            missing `roleArn` / `region` / `destination`, or a non-AWS sink) or
            `endpoint_blocked` (the destination host resolved to a blocked,
            private, or metadata address).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '500':
          $ref: '#/components/responses/InternalError'
      security:
        - BearerAuth: []
components:
  parameters:
    SubscriptionId:
      name: id
      in: path
      required: true
      description: The unique identifier of the subscription (UUIDv7).
      schema:
        type: string
        format: uuid
    IdempotencyKey:
      name: X-Idempotency
      in: header
      required: true
      description: >-
        A client-chosen unique key that makes this mutation at-most-once. A
        mutation sent without it is rejected before any write with `400
        missing_idempotency_key`. Reusing the same key with an identical request
        replays the original response byte-for-byte (with
        `X-Idempotency-Replayed: true`); reusing it with a different request
        body returns `409 idempotency_conflict`. To re-drive a corrected
        request, mint a new key.
      schema:
        type: string
  schemas:
    DelegatedGrantRequest:
      type: object
      additionalProperties: false
      description: >-
        The non-secret AWS delegated-grant coordinates. No AWS credential
        crosses this body — the role is assumed per delivery, guarded by the
        separately minted `ExternalId`.
      properties:
        roleArn:
          type: string
          description: >-
            The cross-account delivery role ARN Streaming Hub assumes at
            delivery time.
          examples:
            - arn:aws:iam::444455556666:role/streaming-hub-delegated-delivery
        region:
          type: string
          description: The AWS region of the destination.
          examples:
            - us-east-1
        destination:
          type: string
          description: >-
            The resolved destination (queue URL or event-bus ARN).
            SSRF-validated before the write.
          examples:
            - https://sqs.us-east-1.amazonaws.com/444455556666/orders
      required:
        - roleArn
        - region
        - destination
    Error:
      type: object
      additionalProperties: false
      description: >-
        The flat error envelope used across the `/v1` and `/admin` surfaces. It
        carries a single low-cardinality, machine-readable token and never leaks
        secret material or internal detail. (A `403` from the authorization
        decision point is the one exception — its body is plain text.)
      properties:
        error:
          type: string
          description: The machine-readable error token.
          examples:
            - not_found
      required:
        - error
  headers:
    IdempotencyReplayed:
      description: >-
        Present and set to `true` when this response is a replay of a previously
        committed request carrying the same `X-Idempotency` key (the handler did
        not run again).
      schema:
        type: string
        enum:
          - 'true'
  responses:
    BadRequestOrMissingIdempotency:
      description: >-
        The request body is malformed (`bad_request`) or the required
        `X-Idempotency` header is missing (`missing_idempotency_key`, rejected
        before any write).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Unauthorized:
      description: >-
        Authentication failed, or there is no trusted tenant context. `error` is
        `unauthorized` (uniform body — no reason is leaked).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Forbidden:
      description: >-
        The authorization decision point denied the request. The body is plain
        text (not the JSON error envelope).
      content:
        text/plain:
          schema:
            type: string
    NotFound:
      description: >-
        The resource is absent, soft-deleted, or owned by another tenant — a
        uniform `error` of `not_found` (no existence oracle).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    IdempotencyConflict:
      description: >-
        An in-flight duplicate, or the same `X-Idempotency` key was reused with
        a different request fingerprint — `error` is `idempotency_conflict`.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    InternalError:
      description: >-
        An infrastructure fault. `error` is `internal_error` (sanitized; detail
        is logged, never returned).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        A bearer JWT issued by plugin-auth (lib-auth). The tenant identity is
        resolved from the validated token claims; the `/v1` surface never reads
        a tenant from the body, path, or query. Machine callers obtain a token
        via the plugin-auth client-credentials flow. The `/admin` surface
        authorizes against an operator scope and carries no tenant context.

````