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

# Get latest logs

> Get the N most recent logs for an environment



## OpenAPI

````yaml https://api.alpic.ai/openapi.json get /v1/environments/{environmentId}/latest-logs
openapi: 3.1.1
info:
  title: Alpic API
  version: 1.0.0
servers:
  - url: https://api.alpic.ai
security:
  - bearerAuth: []
paths:
  /v1/environments/{environmentId}/latest-logs:
    get:
      tags:
        - environments
      summary: Get latest logs
      description: Get the N most recent logs for an environment
      operationId: environments.getLatestLogs.v1
      parameters:
        - name: environmentId
          in: path
          required: true
          schema:
            type: string
            description: The ID of the environment
        - name: limit
          in: query
          schema:
            type: integer
            minimum: 1
            maximum: 1000
            default: 100
            description: Number of most recent log entries to return
          allowEmptyValue: true
          allowReserved: true
        - name: level
          in: query
          schema:
            type: array
            items:
              enum:
                - INFO
                - ERROR
                - WARNING
                - DEBUG
              type: string
            description: Filter by log level
          style: deepObject
          explode: true
          allowEmptyValue: true
          allowReserved: true
        - name: search
          in: query
          schema:
            type: string
            description: Filter pattern to search for in log content
          allowEmptyValue: true
          allowReserved: true
      responses:
        '200':
          description: The latest logs
          content:
            application/json:
              schema:
                type: object
                properties:
                  logs:
                    type: array
                    items:
                      type: object
                      properties:
                        timestamp:
                          type: string
                          format: date-time
                          x-native-type: date
                        type:
                          enum:
                            - START
                            - END
                            - INFO
                            - ERROR
                            - WARNING
                            - DEBUG
                          type: string
                        requestId:
                          type: string
                        content:
                          type: string
                        method:
                          type: string
                        durationInMs:
                          type: number
                      required:
                        - timestamp
                        - type
                        - requestId
                required:
                  - logs
        '400':
          description: '400'
          content:
            application/json:
              schema:
                oneOf:
                  - type: object
                    properties:
                      defined:
                        const: true
                      code:
                        const: BAD_REQUEST
                      status:
                        const: 400
                      message:
                        type: string
                        default: Bad Request
                      data: {}
                    required:
                      - defined
                      - code
                      - status
                      - message
                  - type: object
                    properties:
                      defined:
                        const: false
                      code:
                        type: string
                      status:
                        type: number
                      message:
                        type: string
                      data: {}
                    required:
                      - defined
                      - code
                      - status
                      - message
        '404':
          description: '404'
          content:
            application/json:
              schema:
                oneOf:
                  - type: object
                    properties:
                      defined:
                        const: true
                      code:
                        const: NOT_FOUND
                      status:
                        const: 404
                      message:
                        type: string
                        default: Not Found
                      data: {}
                    required:
                      - defined
                      - code
                      - status
                      - message
                  - type: object
                    properties:
                      defined:
                        const: false
                      code:
                        type: string
                      status:
                        type: number
                      message:
                        type: string
                      data: {}
                    required:
                      - defined
                      - code
                      - status
                      - message
components:
  securitySchemes:
    bearerAuth:
      type: http
      description: >-
        Bearer token for authentication. Use an API key from the API Keys page
        in team settings, or an OAuth access token.
      scheme: bearer

````