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

# Record Sidecar Session Events

> Record a sidecar's audit events as sessions. The sidecar is taken from the token, never the body, and every session it writes is its own.
2xx means the batch is applied, now or by an earlier request: an event at or below its session's last applied seq is ignored. 4xx means the sidecar must not resend the batch; a 422 names the sessions that can never be recorded, and the other sessions of the batch were applied. 5xx means it may resend it as it is.
The organization must have the experimental.sidecar_session_events flag on; the handshake answers the hoop-sidecar-session-events header when it does.



## OpenAPI

````yaml https://use.hoop.dev/api/openapiv3.json post /sidecars/events
openapi: 3.0.3
info:
  contact:
    email: help@hoop.dev
    name: Help
    url: https://help.hoop.dev
  description: >-
    Hoop.dev is an access gateway for databases and servers with an API for
    packet manipulation
  license:
    name: MIT
    url: https://opensource.org/license/mit
  termsOfService: https://hoop.dev/docs/legal/tos
  title: Hoop Api
  version: 1.224.1
servers:
  - url: https://use.hoop.dev/api
security: []
tags:
  - description: >
      Hoop implements Oauth2 and OIDC protocol to authenticate users in the
      system. To obtain a valid access token users need to authenticate in their
      own identity provider which is generated as a JSON response to the
      endpoint `http(s)://use.hoop.dev/api/login`. The identity provider them
      redirects the user to the callback endpoint containing the access token.


      The recommended approach of obtaining an access token is by visiting the
      Webapp main's page or using the **Hoop command line**. Example:


      ```sh

      hoop config create --api-url https://use.hoop.dev

      # save the token after authenticating at $HOME/.hoop/config.toml

      hoop login

      # show token information

      hoop config view --raw

      ```


      With an access token you could use any HTTP client to interact with the
      documented endpoints.

      The token must be sent through the `Authorization` header.


      Example:


      ```sh

      # obtain the current configuration of the server

      curl https://use.hoop.dev/api/serverinfo -H "Authorization: Bearer
      $ACCESS_TOKEN"

      ```
    name: Authentication
  - description: >
      Users are active and assigned to the default organization when they
      signup. A user could be set to an inactive state preventing it from
      accessing the platform, however it’s recommended to manage the state of
      users in the identity provider.


      - The `sub` claim is used as the main identifier of the user in the
      platform.

      - The profile of the user is derived from the id_token claims `email` and
      `name`.


      When a user authenticates for the first time, it performs an automatic
      signup that persist the profile claims along with it’s unique identifier.

      ​

      ### Groups


      Groups allows defining who may access or interact with certain resources.


      - For connection resources it’s possible to define which groups has access
      to a specific connection, this is enforced when the Access Control feature
      is enabled.

      - For review resources, it’s possible to define which groups are allowed
      to approve an execution, this is enforced when the Review feature is
      enabled.


      > This resource could be managed manually via Webapp or propagated by the
      identity provider via ID Token. In this mode, groups are sync when a user
      performs a login.


      ### Roles


      - The `admin` group is a special role that grants full access to all
      resources


      This role should be granted to users that are responsible for managing the
      Gateway. All other users are regular, meaning that they can access their
      own resources and interact with connections.
    name: User Management
  - name: Machine Identities
  - description: Routes used to manage and obtain information about the runtime server.
    name: Server Management
  - description: Features available in the gateway. See also **Plugin** resources.
    name: Features
  - description: >-
      Proxy manager endpoints controls how clients connect via gRPC in the
      gateway. These endpoints are meant to be used when a client is initialized
      via `hoop proxy-manager`.
    name: Proxy Manager
  - name: Connections
  - name: Agents
  - name: Sidecars
  - name: Runbooks
  - name: Guard Rails
  - name: Reviews
  - name: Sessions
  - name: Organization Management
  - name: Reports
  - description: >
      Security audit log API. Only users in the **admin** group can access these
      endpoints.


      Audit log entries record security-relevant events (who performed an
      action, when, on which resource, and whether it succeeded). Use the list
      endpoint with filters to query by actor, resource type, action, outcome,
      or date range. Results are paginated and ordered by `created_at`
      descending.
    name: Audit Logs
paths:
  /sidecars/events:
    post:
      tags:
        - Sidecars
      summary: Record Sidecar Session Events
      description: >-
        Record a sidecar's audit events as sessions. The sidecar is taken from
        the token, never the body, and every session it writes is its own.

        2xx means the batch is applied, now or by an earlier request: an event
        at or below its session's last applied seq is ignored. 4xx means the
        sidecar must not resend the batch; a 422 names the sessions that can
        never be recorded, and the other sessions of the batch were applied. 5xx
        means it may resend it as it is.

        The organization must have the experimental.sidecar_session_events flag
        on; the handshake answers the hoop-sidecar-session-events header when it
        does.
      parameters:
        - description: >-
            The token returned when the sidecar was created. Omit it when
            sending hoop-sidecar-identity.
          in: header
          name: hoop-sidecar-token
          schema:
            type: string
        - description: >-
            A Kubernetes or Google service account JWT, raw, that a sidecar
            service account mapping allows. Omit it when sending
            hoop-sidecar-token.
          in: header
          name: hoop-sidecar-identity
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/openapi.SidecarSessionEventsRequest'
        description: The request body resource
        required: true
        x-originalParamName: request
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/openapi.SidecarSessionEventsResponse'
          description: OK
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/openapi.HTTPError'
          description: Bad Request
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/openapi.HTTPError'
          description: Unauthorized
        '403':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/openapi.HTTPError'
          description: Forbidden
        '412':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/openapi.HTTPError'
          description: Precondition Failed
        '413':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/openapi.HTTPError'
          description: Request Entity Too Large
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/openapi.HTTPError'
          description: Unprocessable Entity
        '500':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/openapi.HTTPError'
          description: Internal Server Error
components:
  schemas:
    openapi.SidecarSessionEventsRequest:
      properties:
        events:
          description: |-
            The events, in the order the sidecar numbered them. At most 500, and
            the body at most 4 MiB; above either the answer is 413
          items:
            $ref: '#/components/schemas/openapi.SidecarSessionEvent'
          type: array
      type: object
    openapi.SidecarSessionEventsResponse:
      properties:
        accepted:
          description: Events applied by this request, the ignored kinds included
          example: 42
          type: integer
        duplicates:
          description: Events at or below their session's last applied seq, ignored
          example: 0
          type: integer
      type: object
    openapi.HTTPError:
      properties:
        message:
          example: the error description
          type: string
      type: object
    openapi.SidecarSessionEvent:
      properties:
        event:
          additionalProperties: {}
          description: |-
            The audit record exactly as the sidecar's JSONL audit file holds it
            (sidecar/audit.Event): kind, timestamp, session_id, principal,
            protocol, connection (the listener), statement, allowed, rule,
            message, error, masked_entities, masked_count and the session totals
          type: object
        seq:
          description: |-
            The event's number in its sidecar session: 1 for the first, one more
            for each after it. An event at or below the last one applied is
            ignored, which makes a resend safe
          example: 1
          type: integer
      type: object

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.