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

# Get app logs

> Returns up to 100 lines of the app's output, newest first by default. How far back you can read depends on your bundle plan's log retention. To page through logs, move `start` or `end` past the last line you received. Team permission: any project permission.



## OpenAPI

````yaml /spec/paas.yaml get /v2/projects/{project_id}/logs
openapi: 3.0.1
info:
  title: Apps & Deployments
  version: 1.0.0
  description: >
    Create apps, deploy them, change their plans and settings, and read

    their logs, metrics and events.


    ## Identifying an app


    Most endpoints identify an app by its **name** (`project_id`, for

    example `my-app`). Some use its **ID** instead (`projectID`, the
    24-character

    `_id` returned when you create or list apps). Each endpoint says which one

    it expects.


    ## Deploying


    1. Upload your source code as a `.tar.gz` or `.zip` archive with
       `POST /v2/projects/{project_id}/sources`. You get a `sourceID`.
    2. Create a release with `POST /v2/projects/{project_id}/releases`, passing
       the `sourceID`. For `docker` apps you can pass a ready-made `image`
       instead.
    3. Follow the build with `GET /v2/releases/{releaseID}/build-logs` and
       check the release `state` with `GET /v1/releases/{releaseID}` until it's
       `READY` (or `FAILED`, `CANCELED`, `TIMEDOUT` or `UNHEALTHY`).

    ## Interactive shell (WebSocket)


    Open a shell in a running app over WebSocket:


    ```text

    wss://api.liara.ir/v1/exec?token=<api-token>&project_id=<app-name>&cmd=<command>

    ```


    - `token`: your API token.

    - `project_id`: the app's name.

    - `cmd`: the command to run, for example `/bin/bash`. URL-encode it.

    - `teamID` (optional): the team that owns the app. You need the `operate`
      or `manage` permission on the app.

    Everything you send is passed to the command's input, and its output is

    sent back to you. If the app has never been deployed successfully, you get

    the message `Service does not exist yet. You should have at least one

    successful release.` and the connection closes. The handshake fails with

    `401` for a missing or invalid token, `400` if `project_id` or `cmd` is

    missing or `teamID` is invalid, `403` without access to the team or app,

    and `404` if the app doesn't exist.


    ## Team permissions


    With `teamID`, each endpoint needs one of the project permissions it lists

    (`view`, `deploy`, `operate` or `manage`). A permission from your role or

    a resource permission on that app both count.
servers:
  - url: https://api.liara.ir
security:
  - bearerAuth: []
tags:
  - name: Apps
    description: Create, list, inspect and delete apps.
  - name: Configuration
    description: Environment variables, port, DNS servers, plans and scaling.
  - name: Settings
    description: >-
      Read-only filesystem, default subdomain, zero-downtime deployment and
      fixed outbound IP.
  - name: Deployments
    description: Upload source code, create releases, follow builds and roll back.
  - name: Logs, Metrics & Events
    description: Runtime logs, resource usage and lifecycle events.
  - name: Networks
    description: Private networks that apps and databases are created in.
paths:
  /v2/projects/{project_id}/logs:
    get:
      tags:
        - Logs, Metrics & Events
      summary: Get app logs
      description: >-
        Returns up to 100 lines of the app's output, newest first by default.
        How far back you can read depends on your bundle plan's log retention.
        To page through logs, move `start` or `end` past the last line you
        received. Team permission: any project permission.
      operationId: getLogs
      parameters:
        - $ref: '#/components/parameters/TeamID'
        - $ref: '#/components/parameters/AppName'
        - $ref: '#/components/parameters/LogStart'
        - $ref: '#/components/parameters/LogEnd'
        - $ref: '#/components/parameters/LogDirection'
        - $ref: '#/components/parameters/AppletId'
        - $ref: '#/components/parameters/ReleaseIdFilter'
        - name: search
          in: query
          required: false
          description: Only return lines containing this text. At least 3 characters.
          schema:
            type: string
            minLength: 3
        - name: last_lines
          in: query
          required: false
          description: >-
            Send `true` to get the newest lines from your whole retention
            period, ignoring `start` and `direction`.
          schema:
            type: boolean
            default: false
      responses:
        '200':
          description: Log lines, grouped by instance and release.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        metaData:
                          $ref: '#/components/schemas/LogStreamMetaData'
                        values:
                          type: array
                          description: >-
                            `[timestamp, line]` pairs. The timestamp is in
                            nanoseconds since the Unix epoch, as a string.
                          items:
                            type: array
                            items:
                              type: string
              example:
                data:
                  - metaData:
                      appletId: <instance-id>
                      releaseId: '000000000000000000000170'
                    values:
                      - - '1767254400000000000'
                        - Server listening on port 3000
        '204':
          description: The app has no releases yet, so there are no logs.
        '400':
          $ref: '#/components/responses/ValidationOrTeamIDError'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/TeamForbidden'
        '404':
          $ref: '#/components/responses/AppNotFound'
        '409':
          $ref: '#/components/responses/AppletAndReleaseConflict'
        '428':
          $ref: '#/components/responses/InvalidLogRange'
        '503':
          $ref: '#/components/responses/TemporarilyUnavailable'
components:
  parameters:
    TeamID:
      name: teamID
      in: query
      required: false
      description: >-
        Run the request in the context of a team you belong to, instead of your
        personal account.
      schema:
        $ref: '#/components/schemas/ObjectID'
      example: '000000000000000000000002'
    AppName:
      name: project_id
      in: path
      required: true
      description: The app's name.
      schema:
        type: string
      example: my-app
    LogStart:
      name: start
      in: query
      required: false
      description: >-
        Start of the range, in Unix seconds. It can't be further back than your
        bundle plan's log retention. If omitted, the last hour is used.
      schema:
        type: integer
    LogEnd:
      name: end
      in: query
      required: false
      description: >-
        End of the range, in Unix seconds. Defaults to now. Must be after
        `start`.
      schema:
        type: integer
    LogDirection:
      name: direction
      in: query
      required: false
      description: '`backward` returns the newest entries first, `forward` the oldest first.'
      schema:
        type: string
        enum:
          - backward
          - forward
        default: backward
    AppletId:
      name: appletId
      in: query
      required: false
      description: >-
        Only include one instance of the app (an `appletId` from a previous
        response). Can't be combined with `releaseId`.
      schema:
        type: string
    ReleaseIdFilter:
      name: releaseId
      in: query
      required: false
      description: Only include one release. Can't be combined with `appletId`.
      schema:
        type: string
  schemas:
    LogStreamMetaData:
      type: object
      properties:
        appletId:
          type: string
          description: The instance that wrote the lines.
        releaseId:
          type: string
          description: The release the instance belongs to.
    ObjectID:
      type: string
      pattern: ^[0-9a-fA-F]{24}$
      description: 24-character hexadecimal ID.
    Error:
      type: object
      description: Standard error body.
      properties:
        statusCode:
          type: integer
        error:
          type: string
          description: HTTP status text.
        message:
          type: string
          description: What went wrong.
        data:
          type: object
          nullable: true
          description: >-
            Extra details. When present, `code` is a stable, machine-readable
            error code.
          properties:
            code:
              type: string
    AuthError:
      type: object
      description: Error body returned when the API token is rejected.
      properties:
        error:
          type: string
  responses:
    ValidationOrTeamIDError:
      description: >-
        The body or a parameter is invalid (`message` says which), or `teamID`
        isn't a valid ID.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          examples:
            validation:
              summary: Invalid parameter
              value:
                statusCode: 400
                error: Bad Request
                message: '"since" is required'
            invalidTeamID:
              summary: Invalid team ID
              value:
                statusCode: 400
                error: Bad Request
                message: Invalid team ID.
                data: null
    Unauthorized:
      description: The API token is missing, invalid or expired.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/AuthError'
          example:
            error: Unauthorized.
    TeamForbidden:
      description: >-
        With `teamID`: you aren't a member of the team (`team_not_found`), or
        you don't have the required permission on this app (`no_permission`).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          examples:
            teamNotFound:
              summary: Not a team member
              value:
                statusCode: 403
                error: Forbidden
                message: Team not found
                data:
                  code: team_not_found
            noPermission:
              summary: Missing permission
              value:
                statusCode: 403
                error: Forbidden
                message: You do not have permission to access this resource.
                data:
                  code: no_permission
    AppNotFound:
      description: The app doesn't exist.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            statusCode: 404
            error: Not Found
            message: Not Found
            data: null
    AppletAndReleaseConflict:
      description: You sent both `appletId` and `releaseId`.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            statusCode: 409
            error: Conflict
            message: You can only specify appletId or releaseId
            data: null
    InvalidLogRange:
      description: >-
        `start` is further back than your bundle plan's log retention, or `end`
        isn't after `start`.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            statusCode: 428
            error: Precondition Required
            message: '"start" must be at most 30 days ago'
            data: null
    TemporarilyUnavailable:
      description: The data is temporarily unavailable. Try again later.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            statusCode: 503
            error: Service Unavailable
            message: Service Unavailable
            data: null
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: 'Send your API token as `Authorization: Bearer <api-token>`.'

````

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