# Download a repository archive

Streams the repository at a ref as a gzip-compressed tar archive. Narrow it with `includeGlob`, `excludeGlob`, and `maxBlobSize`, and set `archivePrefix` to nest every path under one directory.

## GET `/v1/spaces/{spaceId}/source/archive`

### Authorization

`Authorization` Bearer token · header required  
\`Authorization: Bearer <token>\` with an API key (\`sfa\_\` prefix), an OAuth access token, a session token, or a Space machine credential (\`sfm\_\` prefix).

or

`Authorization` OAuth2 access token · header required

OAuth 2.0 with Spacefast scopes. People use the authorization code flow; machines use client credentials.

**Scopes:** `spaces:read`

### Path parameters

`spaceId` string required

### Query parameters

`connectionType` string required  
default: "connected"  
Allowed: `connected` `hosted`

`ref` string  
min length 1

`includeGlob` string | string[]

`excludeGlob` string | string[]

`maxBlobSize` integer  
max 104857600

`archivePrefix` string  
min length 1

### Responses

**200** The repository at the requested ref, as a gzip-compressed tar archive.

`string<binary>`

**default** Error. Every 4xx and 5xx response is one RFC 9457 problem document served as \`application/problem+json\`.

```json
{
  "$schema": "string<uri>",
  "type": "string",
  "title": "string",
  "status": 200,
  "detail": "Human-readable name of the error type.",
  "code": "string",
  "pointer": "string",
  "details": {
    "property1": null,
    "property2": null
  },
  "suggestions": [
    "string"
  ],
  "next": [
    "string"
  ],
  "requestId": "string"
}
```

### Try it

**Server**

Base URL: https://api.spacefast.com

Custom base URL Overrides the selected server when set.

### Request Example

**cURL:**

```bash
curl -X GET "https://api.spacefast.com/v1/spaces/string/source/archive?connectionType=connected" \
  -H "Authorization: Bearer YOUR_TOKEN"
```

**JavaScript:**

```javascript
const response = await fetch("https://api.spacefast.com/v1/spaces/string/source/archive?connectionType=connected", {
  method: "GET",
  headers: {
    "Authorization": "Bearer YOUR_TOKEN"
  }
});
```

**Python:**

```python
import requests

response = requests.get(
    "https://api.spacefast.com/v1/spaces/string/source/archive?connectionType=connected",
    headers={
        "Authorization": "Bearer YOUR_TOKEN"
    },
)
```

### Response Example

**200 default**

```json
"string"
```
