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

# Configure log export

> Set up the S3 log export or change its destination or schedule

Sets up the workspace's [S3 log export](https://docs.macroscope.com/s3-exports), or changes its destination or schedule, as **Log Export** in workspace settings does. Each attempt, including a refused or invalid one, is recorded in the workspace audit log with its outcome and the API key, or the person and connected app, that made it. Requests rejected before they reach the operation, such as malformed requests, invalid credentials and rate-limited requests, may have no entry. The audit log shows the role ARN redacted.

Before saving, Macroscope verifies S3 access: it assumes the IAM role and writes a small validation object under the key prefix. If verification fails, nothing changes and an existing export keeps its destination. If the check cannot be completed, for example because S3 is temporarily unavailable or throttling, the request returns `503` and also changes nothing. Only an answer from AWS about the destination, such as access denied or a missing bucket, counts as a failed verification. The role must trust Macroscope's export identity for this workspace, as described in [S3 exports](https://docs.macroscope.com/s3-exports), and each workspace needs its own role.

> [!WARNING]
>
> Saving re-baselines the export schedule: data since the last export is not backfilled. Saving also resumes a paused export. To change only which streams are exported, or to pause the export, use [Update log export](https://docs.macroscope.com/api-reference/endpoint/update-log-export.md).

Configuring needs an active subscription. Each workspace can make 5 configuration attempts per minute, shared with **Log Export** in workspace settings; further attempts return `429`.

## Authorization

Requires an **Admin** API key, or an [OAuth sign-in](https://docs.macroscope.com/api-reference/mcp.md#permissions) with **Admin** access by a person who is a workspace admin. Read and Write keys get `403`, and a sign-in with Read or Write access gets an `insufficient_scope` challenge for `macroscope:admin`.

**Authorization** `string` *required*

`Bearer <key>`. See [Authentication](https://docs.macroscope.com/api#authentication).

**X-Macroscope-Initiation** `string`

How your client identifies the source of the request in the workspace audit log. Use `human` or `agent`. Macroscope records the client's value without verifying it. Other values are treated as unspecified.

## Path parameters

**workspaceType** `string` *required*

`GITHUB_ORGANIZATION` or `GITHUB_USER`.

**workspaceId** `string` *required*

Numeric GitHub ID of the organization or user.

## Body

**bucketName** `string` *required*

S3 bucket name.

**bucketRegion** `string` *required*

AWS region of the bucket, such as `us-east-1`.

**roleArn** `string` *required*

ARN of the IAM role Macroscope assumes to write exports. Responses and the audit log show it redacted.

**keyPrefix** `string`

Key prefix to write exports under, ending in `/`. Omit or leave empty for the bucket root.

**exportFrequency** `string` *required*

`hourly` or `daily`.

**exportActivityLogs** `boolean`

Whether user activity logs, the workspace audit log events, are exported. Omitted keeps the current value, or exports them when setting up a new export.

**exportCheckRunLogs** `boolean`

Whether check run logs are exported. Omitted keeps the current value, or exports them when setting up a new export.

**exportCodeReviewAnalytics** `boolean`

Whether code review analytics are exported. Omitted keeps the current value, or exports them when setting up a new export. At least one stream must be on.

## Response

**logExport** `LogExport`

The log export as saved, in the same form as [Get log export](https://docs.macroscope.com/api-reference/endpoint/get-log-export.md).

## Errors

<table>
  <colgroup>
    <col width="100" />

    <col width="698" />
  </colgroup>

  <thead>
    <tr>
      <th>HTTP</th>
      <th>Meaning</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>`400`</td>
      <td>Invalid destination (bucket name, region, role ARN, key prefix or frequency), no stream on, S3 access verification failed, or the role is already used by another workspace. Nothing was changed</td>
    </tr>

    <tr>
      <td>`403`</td>
      <td>Your credential or your permissions do not allow managing the log export, or the workspace has no active subscription</td>
    </tr>

    <tr>
      <td>`404`</td>
      <td>The workspace does not have log export</td>
    </tr>

    <tr>
      <td>`409`</td>
      <td>The log export changed while the destination was being verified. Read it again before retrying</td>
    </tr>

    <tr>
      <td>`429`</td>
      <td>Too many configuration attempts for the workspace. Try again in a minute</td>
    </tr>

    <tr>
      <td>`503`</td>
      <td>The destination could not be verified right now. Nothing was changed; try again in a few minutes</td>
    </tr>
  </tbody>
</table>

See [Errors](https://docs.macroscope.com/api#errors) for the rest.

```bash cURL theme={null}
curl -X PUT https://api.macroscope.com/api/v1/workspaces/GITHUB_ORGANIZATION/12345678/logExport \
  -H "Authorization: Bearer $MACROSCOPE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"bucketName": "acme-macroscope-logs", "bucketRegion": "us-east-1", "roleArn": "arn:aws:iam::123456789012:role/macroscope-export", "keyPrefix": "macroscope/", "exportFrequency": "hourly"}'
```

```json 200 theme={null}
{
  "logExport": {
    "destinationType": "S3",
    "bucketName": "acme-macroscope-logs",
    "bucketRegion": "us-east-1",
    "roleArnRedacted": "arn:aws:iam::123456789012:role/•••••••••••••port",
    "keyPrefix": "macroscope/",
    "exportFrequency": "hourly",
    "exportCheckRunLogs": true,
    "exportActivityLogs": true,
    "enabled": true,
    "nextExportAt": "2026-11-29T05:00:00Z",
    "lastWindowEnd": "2026-11-29T04:00:00Z",
    "createdAt": "2026-10-02T17:20:00Z"
  }
}
```

```json 401 theme={null}
{ "code": 16, "message": "unauthenticated" }
```


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