> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.runtype.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.runtype.com/_mcp/server.

# Upload a managed deployment source bundle

POST https://api.runtype.com/v1/sandbox-deployments/sources
Content-Type: application/gzip

Streams one gzipped tar of authored source. The body is verified against the declared SHA-256 digest and rejected before storage on any traversal, link, device, duplicate-path, file-count or size violation. Identity is organization + environment + content hash, so re-uploading identical bytes returns the existing manifest.

Reference: https://docs.runtype.com/api-reference/runtype-api/sandbox-deployments/upload-a-managed-deployment-source-bundle

## Authentication

- `Authorization` header (bearer token, required) — API key or Clerk session token

## Servers

- `https://api.runtype.com` (Production, default)
- `https://api.runtype-staging.com` (Staging)

## Request

### Query parameters

- `environment` (enum, required)
  - Allowed values: `development`, `staging`, `production`
- `language` (enum, required)
  - Allowed values: `javascript`, `typescript`, `python`
- `digest` (string, required)

### Body (application/gzip)

This endpoint expects binary data of type application/gzip.

- Binary request body.

## Response

### 201

Source manifest registered

- `compressedBytes` (integer, required)
- `dependencyLock` (enum, required)
  - Allowed values: `none`, `pnpm-lock`, `python-hashes`
- `environment` (enum, required)
  - Allowed values: `development`, `staging`, `production`
- `expandedBytes` (integer, required)
- `fileCount` (integer, required)
- `reused` (boolean, required)
- `sourceAssetId` (string, required)
- `sourceHash` (string, required)

## Errors

### 400 Bad Request Error

Validation error

- `error` (string, required)
- `details` (list of ErrorDetailsItems, optional)

### 401 Unauthorized Error

Unauthorized

- `error` (string, required)
- `details` (list of ErrorDetailsItems, optional)

### 402 Payment Required Error

Blocked by the organization managed deployment spend budget or credits

- `error` (string, required)
- `details` (list of ErrorDetailsItems, optional)

### 403 Forbidden Error

Insufficient permissions

- `error` (string, required)
- `details` (list of ErrorDetailsItems, optional)

### 404 Not Found Error

Not found

- `error` (string, required)
- `details` (list of ErrorDetailsItems, optional)

### 409 Conflict Error

Conflict

- `error` (string, required)
- `details` (list of ErrorDetailsItems, optional)

### 412 Precondition Failed Error

Resource version precondition failed

- `error` (string, required)
- `details` (list of ErrorDetailsItems, optional)

### 422 Unprocessable Entity Error

Blocked by credential, source, or profile admission

- `error` (string, required)
- `details` (list of ErrorDetailsItems, optional)

### 429 Too Many Requests Error

Organization quota exhausted

- `error` (string, required)
- `details` (list of ErrorDetailsItems, optional)

### 500 Internal Server Error

Internal server error

- `error` (string, required)
- `details` (list of ErrorDetailsItems, optional)

### 503 Service Unavailable Error

Deployment source storage is not configured

- `error` (string, required)
- `details` (list of ErrorDetailsItems, optional)

## Types

### ErrorDetailsItems

- `message` (string, required)
- `code` (string, optional) — Stable Runtype validation code (e.g. MISSING_REQUIRED_FIELD, INVALID_ENUM).
- `path` (string, optional) — Dotted JSON path to the offending field.
- `suggestion` (string, optional) — Actionable hint (allowed values, accepted range, …).

## Examples

**Request**

```json
{}
```

**Response**

```json
{
  "compressedBytes": 184320,
  "dependencyLock": "pnpm-lock",
  "environment": "development",
  "expandedBytes": 512000,
  "fileCount": 47,
  "reused": false,
  "sourceAssetId": "src_01HQ8K3VZMJ4N5P6R7T9W2X4YZ",
  "sourceHash": "a3f1c2e4b5d6789012345678901234567890abcdef1234567890abcdef123456"
}
```

**SDK Code**

```python
import requests

url = "https://api.runtype.com/v1/sandbox-deployments/sources"

querystring = {"digest":"digest","environment":"development","language":"javascript"}

payload = "{}"
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/gzip"
}

response = requests.post(url, data=payload, headers=headers, params=querystring)

print(response.json())
```

```javascript
const url = 'https://api.runtype.com/v1/sandbox-deployments/sources?digest=digest&environment=development&language=javascript';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/gzip'},
  body: '{}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.runtype.com/v1/sandbox-deployments/sources?digest=digest&environment=development&language=javascript"

	payload := strings.NewReader("{}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/gzip")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.runtype.com/v1/sandbox-deployments/sources?digest=digest&environment=development&language=javascript")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/gzip'
request.body = "{}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.runtype.com/v1/sandbox-deployments/sources?digest=digest&environment=development&language=javascript")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/gzip")
  .body("{}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.runtype.com/v1/sandbox-deployments/sources?digest=digest&environment=development&language=javascript', [
  'body' => '{}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/gzip',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.runtype.com/v1/sandbox-deployments/sources?digest=digest&environment=development&language=javascript");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/gzip");
request.AddParameter("application/gzip", "{}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/gzip"
]

let postData = NSData(data: "{}".data(using: String.Encoding.utf8)!)

let request = NSMutableURLRequest(url: NSURL(string: "https://api.runtype.com/v1/sandbox-deployments/sources?digest=digest&environment=development&language=javascript")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```