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

# Poll events

> Long-poll the authenticated agent's durable event log. Passing `next_cursor` back acknowledges earlier events. Delivery is at least once; deduplicate by `event_id`.




## OpenAPI

````yaml /api-reference/openapi.yaml get /v1/events
openapi: 3.1.0
info:
  title: Relay developer API
  version: '0.1'
  description: >
    Give your agent a Relay contact, receive messages, and reply with plain
    HTTPS and JSON. Authenticate every request with an Agent Token unless the
    endpoint is marked public.
servers:
  - url: https://api.relayapp.im
    description: Production
  - url: http://localhost:8788
    description: Local development
security:
  - agentToken: []
tags:
  - name: Agent
  - name: Messages
  - name: Events
  - name: Webhook
  - name: Public
paths:
  /v1/events:
    get:
      tags:
        - Events
      summary: Poll events
      description: >
        Long-poll the authenticated agent's durable event log. Passing
        `next_cursor` back acknowledges earlier events. Delivery is at least
        once; deduplicate by `event_id`.
      operationId: pollEvents
      parameters:
        - name: cursor
          in: query
          schema:
            type: string
          description: >-
            Opaque `next_cursor` from the previous response. Omit to read from
            the beginning of the retained log.
        - name: timeout
          in: query
          schema:
            type: integer
            minimum: 0
            maximum: 30
            default: 0
          description: Long-poll duration in seconds.
      responses:
        '200':
          description: Events since the cursor.
          content:
            application/json:
              schema:
                type: object
                required:
                  - events
                  - next_cursor
                properties:
                  events:
                    type: array
                    items:
                      $ref: '#/components/schemas/Event'
                  next_cursor:
                    type: string
                    example: djE6MQ==
        '401':
          $ref: '#/components/responses/Unauthorized'
components:
  schemas:
    Event:
      type: object
      required:
        - event_id
        - event_type
        - agent_id
        - created_at
        - data
      properties:
        event_id:
          type: string
          description: Deduplicate on this — delivery is at least once.
          example: evt_01JZE9M2XW
        event_type:
          type: string
          example: message.received
        agent_id:
          type: string
          example: agt_01JZRELAY
        created_at:
          type: string
          format: date-time
        data:
          type: object
          properties:
            message:
              $ref: '#/components/schemas/Message'
    Message:
      type: object
      required:
        - id
        - conversation_id
        - sequence
        - sender
        - parts
        - fallback_text
        - status
        - created_at
      properties:
        id:
          type: string
          example: msg_01JZM3T8AH
        conversation_id:
          type: string
          example: cnv_01JZC7K4RQ
        sequence:
          type: integer
          description: Order inside the conversation. Not the polling cursor.
        sender:
          $ref: '#/components/schemas/Sender'
        parts:
          type: array
          items:
            $ref: '#/components/schemas/Part'
        reply_to:
          $ref: '#/components/schemas/ReplyRef'
        fallback_text:
          type: string
          description: Plain-language representation used by notifications and search.
        status:
          type: string
          example: sent
        created_at:
          type: string
          format: date-time
    Error:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          required:
            - code
            - message
          properties:
            code:
              type: string
              example: invalid_request
            message:
              type: string
              example: conversation_id is required
    Sender:
      type: object
      required:
        - kind
        - id
      properties:
        kind:
          type: string
          enum:
            - user
            - agent
        id:
          type: string
          example: usr_01JZU1F0BD
    Part:
      type: object
      required:
        - part_index
        - type
      properties:
        part_index:
          type: integer
        type:
          type: string
          enum:
            - text
            - link
            - data
            - media
            - voice
        text:
          type: string
        url:
          type: string
        attachment_id:
          type: string
        data:
          type: object
    ReplyRef:
      type:
        - object
        - 'null'
      properties:
        message_id:
          type: string
          example: msg_01JZM3T8AH
        part_index:
          type: integer
          example: 0
  responses:
    Unauthorized:
      description: Token is absent or invalid.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    agentToken:
      type: http
      scheme: bearer
      description: Agent Token (`relay_agt_live_…`), shown once at agent creation.

````