# Download an execution output

Fetch the exact bytes selected by view during an execution.

`GET https://api.smallworld.sh/api/v1/executions/:executionId/outputs/:outputId/content`

## Parameters

| Name | Location | Type | Required | Description |
| --- | --- | --- | --- | --- |
| executionId | path | UUID | Yes | The ID returned in execution.id. |
| outputId | path | UUID | Yes | The id in execution.outputFiles. |

## Request examples

### curl

```curl
curl --fail-with-body -X GET 'https://api.smallworld.sh/api/v1/executions/01995e57-3027-7557-a233-009ea3dcd8fc/outputs/909e0ae1-f9c7-4a58-af88-c3e23e13707f/content' \
  -H "Authorization: Bearer $SMALLWORLD_API_KEY" --output output-file
```

### typescript

```typescript
const response = await fetch("https://api.smallworld.sh/api/v1/executions/01995e57-3027-7557-a233-009ea3dcd8fc/outputs/909e0ae1-f9c7-4a58-af88-c3e23e13707f/content", {
  headers: { Authorization: `Bearer ${apiKey}` },
});
if (!response.ok) throw new Error(`HTTP ${response.status}`);
const bytes = new Uint8Array(await response.arrayBuffer());
```

### python

```python
response = requests.get("https://api.smallworld.sh/api/v1/executions/01995e57-3027-7557-a233-009ea3dcd8fc/outputs/909e0ae1-f9c7-4a58-af88-c3e23e13707f/content", headers={"Authorization": f"Bearer {api_key}"}, timeout=30)
response.raise_for_status()
content = response.content
```

## Responses

The body contains the saved bytes. Content-Type identifies the media type and Content-Disposition supplies the filename. Selected images open inline and explicit downloads are served as attachments.

### 200

The body contains the saved bytes. Content-Type identifies the media type and Content-Disposition supplies the filename. Selected images open inline and explicit downloads are served as attachments.

```text
item,quantity
widgets,17

```

### 400

invalid_request: A parameter is invalid; the message names the problem. Unknown query parameters are rejected.

#### invalid_request

A parameter is invalid; the message names the problem. Unknown query parameters are rejected.

```json
{
  "statusCode": 400,
  "code": "invalid_request",
  "message": "Unknown query parameter: color"
}
```

### 401

authentication_required: The Authorization header is missing or empty. invalid_api_key: The API key is invalid or revoked, or the header doesn't use the Bearer scheme.

#### authentication_required

The Authorization header is missing or empty.

```json
{
  "statusCode": 401,
  "code": "authentication_required",
  "message": "Authentication is required"
}
```

#### invalid_api_key

The API key is invalid or revoked, or the header doesn't use the Bearer scheme.

```json
{
  "statusCode": 401,
  "code": "invalid_api_key",
  "message": "The API key is invalid or revoked"
}
```

### 403

ip_not_allowed: The request came from an address outside the workspace's IP allowlist.

#### ip_not_allowed

The request came from an address outside the workspace's IP allowlist.

```json
{
  "statusCode": 403,
  "code": "ip_not_allowed",
  "message": "The source IP address is not allowed by this account's security settings"
}
```

### 404

execution_output_not_found: The execution or selected output is unavailable to this API key.

#### execution_output_not_found

The execution or selected output is unavailable to this API key.

```json
{
  "statusCode": 404,
  "code": "execution_output_not_found",
  "message": "Execution output not found"
}
```

### 500

internal_error: An unexpected server error.

#### internal_error

An unexpected server error.

```json
{
  "statusCode": 500,
  "code": "internal_error",
  "message": "Internal server error"
}
```

## Notes

- The contentPath returned by execute includes /api/v1. Resolve it against the API origin. Keep the API key on your server.

- Outputs belong to the saved execution. Later edits, moves, and deletions of their source files do not change a saved output.
