# Organization API: Organization deployments: Logs

> The 3 Organization API operations for logs.

Source: https://www.coritan.com/docs/api/reference/organizations/organization-deployments/deployments-logs/

Part of [Organization deployments](/docs/api/reference/organizations/organization-deployments/).

## Operations

| Method | Path | Summary |
| --- | --- | --- |
| GET | [`/api/v1/orgs/{org_slug}/deployments/{deployment_uuid}/logs`](#op-get-api-v1-orgs-org-slug-deployments-deployment-uuid-logs) | Get logs |
| GET | [`/api/v1/orgs/{org_slug}/deployments/{deployment_uuid}/logs/instances`](#op-get-api-v1-orgs-org-slug-deployments-deployment-uuid-logs-instances) | Get log instances |
| GET | [`/api/v1/orgs/{org_slug}/deployments/{deployment_uuid}/logs/stream`](#op-get-api-v1-orgs-org-slug-deployments-deployment-uuid-logs-stream) | Stream logs |

### Get logs {#op-get-api-v1-orgs-org-slug-deployments-deployment-uuid-logs}

`GET /api/v1/orgs/{org_slug}/deployments/{deployment_uuid}/logs`

The newest ``limit`` lines that match, oldest first within the page
so a terminal prints them in order, and ``next``: the cursor for the
page before it (pass it as ``before``), or null at the oldest line
kept. Lines are kept for the plan's ``deploy_log_retention_days``
(``retention_days``); ``partial`` says a stored chunk could not be read
or the page stopped at its read budget, and ``next`` continues after
it. Each line: ``id`` (``<chunk>:<n>``), ``ts`` (when it was
collected, within a minute of when it was printed), ``instance``,
``process``, ``location``, ``release``, ``message``, and ``gap`` (lines
may be missing just before it). As NDJSON the lines are the body and
``next`` is the ``X-Coritan-Next`` header. 503 ``logs_unavailable``
when the log bucket is not set up.

#### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `deployment_uuid` | path | string (uuid) | yes |  |
| `org_slug` | path | string | yes |  |
| `since` | query | string or null | no | Oldest line: ISO 8601, a Unix time, or a duration back from now (15m, 2h, 7d) |
| `until` | query | string or null | no | Newest line, in the same forms |
| `instance` | query | integer or null | no | An instance id from /logs/instances |
| `process` | query | string or null | no | web, worker, ... |
| `q` | query | string or null | no | Lines containing this text, ignoring case |
| `limit` | query | integer | no | Lines on the page: the newest that match Default: `100`. |
| `before` | query | string or null | no | The next cursor of the page after this one |
| `format` | query | string or null | no | ndjson: one line per row; also chosen by Accept: application/x-ndjson |

#### Responses

| Status | Meaning |
| --- | --- |
| `200` | Success. |
| `422` | The request is not valid. `detail` lists each problem. |

### Get log instances {#op-get-api-v1-orgs-org-slug-deployments-deployment-uuid-logs-instances}

`GET /api/v1/orgs/{org_slug}/deployments/{deployment_uuid}/logs/instances`

The deployment's instances that are live or have lines kept, newest
first: ``id`` (what ``instance`` takes), ``location``, ``process``,
``release``, ``state``, ``live``, ``sleeping``, ``created_at`` and
``last_line_at``.

#### Parameters

| Name | In | Type | Required |
| --- | --- | --- | --- |
| `deployment_uuid` | path | string (uuid) | yes |
| `org_slug` | path | string | yes |

#### Responses

| Status | Meaning |
| --- | --- |
| `200` | Success. |
| `422` | The request is not valid. `detail` lists each problem. |

### Stream logs {#op-get-api-v1-orgs-org-slug-deployments-deployment-uuid-logs-stream}

`GET /api/v1/orgs/{org_slug}/deployments/{deployment_uuid}/logs/stream`

``text/event-stream`` of the running instances' output (ten at
most), polled from their consoles every two seconds: ``ready``
(``instances``, ``until``, ``poll_seconds``), then ``line`` events
shaped as ``/logs`` lines (``id`` is ``live:<instance>:<n>``),
``instance`` when one's console cannot be read, a ``: keepalive``
comment after fifteen quiet seconds, and ``end`` with ``reason``:
``time_limit`` after ``seconds``, ``gone`` when the deployment is no
longer the caller's, ``unavailable`` when consoles cannot be read
here. Reconnect for more; a tail does not replay what an earlier one
sent. 429 ``too_many_streams`` past five open at once for the account
(on an organization's routes, for the organization), whichever keys,
sign-ins or members opened them, and ``rate_limited`` past thirty
opened by one caller in ten minutes.

#### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `deployment_uuid` | path | string (uuid) | yes |  |
| `org_slug` | path | string | yes |  |
| `instance` | query | integer or null | no | Only this instance: an id from /logs/instances |
| `process` | query | string or null | no | Only this process's instances: web, worker, ... |
| `q` | query | string or null | no | Lines containing this text, ignoring case |
| `tail` | query | integer | no | Lines each instance's console already holds to start with Default: `50`. |
| `seconds` | query | integer | no | How long the stream stays open Default: `300`. |

#### Responses

| Status | Meaning |
| --- | --- |
| `200` | Success. |
| `422` | The request is not valid. `detail` lists each problem. |
