---
title: "Create Compilation Job"
description: "Asynchronously create a compile job request for a project"
canonical: https://www.quantconnect.com/docs/v2/cloud-platform/api-reference/compiling-code/create-compilation-job
markdown: https://www.quantconnect.com/docs/v2/cloud-platform/api-reference/compiling-code/create-compilation-job.md
language: python
source: https://github.com/QuantConnect/Documentation/tree/master/01%20Cloud%20Platform/99%20API%20Reference/04%20Compiling%20Code/01%20Create%20Compilation%20Job
modified: 2026-10-29
index: https://www.quantconnect.com/llms.txt
---

# Create Compilation Job

[Documentation](https://www.quantconnect.com/docs/v2.md) > [Cloud Platform](https://www.quantconnect.com/docs/v2/cloud-platform.md) > [API Reference](https://www.quantconnect.com/docs/v2/cloud-platform/api-reference.md) > [Compiling Code](https://www.quantconnect.com/docs/v2/cloud-platform/api-reference/compiling-code.md) > Create Compilation Job

> Code examples are shown in Python. Append `?lang=csharp` to this URL for the C# version of this page.

## Introduction

Asynchronously create a compile job request for a project.

## Request

Project Id specifying project to build. The `/compile/create` API accepts requests in the following format:

| `CreateCompileRequest` Model - Request to compile a project. |  |
| --- | --- |
| projectId | `integer required example: 23456789` Id of the project to compile. |
| Example | `{ "projectId": 23456789 }` |

## Responses

The `/compile/create` API provides a response in the following format:

### 200 Success

| `CreateCompileResponse` Model - Response received from creating a compile job. |  |
| --- | --- |
| compileId | `string example: 5d1f2cba3a0ec7407c566614300502b5-173e0419674daf4144ce7c9931155ca8` Compile Id for a successful build. |
| state | `string Enum` The current state of the compile job. Options : ['InQueue', 'BuildSuccess', 'BuildError'] |
| parameters | `FileParameters Array` List of files and their associated parameters detected during compilation. |
| projectId | `integer example: 23456789` Id of the project you requested to compile. |
| signature | `string` Signature key of compilation. |
| signatureOrder | `string Array` Signature order of files to be compiled. |
| success | `boolean` Indicate if the API request was successful. |
| errors | `string Array` List of errors with the API call. |
| Example | `{ "compileId": "5d1f2cba3a0ec7407c566614300502b5-173e0419674daf4144ce7c9931155ca8", "state": "InQueue", "parameters": [ { "file": "__init__.py", "parameters": [ { "line": 8, "type": "3 LEAN API parameters detected near "self.set_start_date(2024, 1, 3)"." } ] } ], "projectId": 23456789, "signature": "string", "signatureOrder": [ "string" ], "success": true, "errors": [ "string" ] }` |

| `FileParameters` Model |  |
| --- | --- |
| file | `string example: __init__.py` Path of the file in the project. |
| parameters | `ParameterDetail Array` List of parameters detected in the file. |
| Example | `{ "file": "__init__.py", "parameters": [ { "line": 8, "type": "3 LEAN API parameters detected near "self.set_start_date(2024, 1, 3)"." } ] }` |

| `ParameterDetail` Model |  |
| --- | --- |
| line | `integer example: 8` Line number where the parameter was detected. |
| type | `string example: 3 LEAN API parameters detected near "self.set_start_date(2024, 1, 3)".` Description of the detected parameter. |
| Example | `{ "line": 8, "type": "3 LEAN API parameters detected near "self.set_start_date(2024, 1, 3)"." }` |

### 401 Authentication Error

| `UnauthorizedError` Model - Unauthorized response from the API. Key is missing, invalid, or timestamp is too old for hash. |  |
| --- | --- |
| www_authenticate | `string` Header |

## Examples

The following example demonstates creating, and reading a compilation job through the cloud API.

```
from base64 import b64encode
from hashlib import sha256
from time import time
from requests import get, post
BASE_URL = 'https://www.quantconnect.com/api/v2/'

# You need to replace these with your actual credentials.
# You can request your credentials at https://www.quantconnect.com/settings/
# You can find our organization ID at https://www.quantconnect.com/organization/
USER_ID = 0
API_TOKEN = '____'
ORGANIZATION_ID = '____'

def get_headers():
    # Get timestamp
    timestamp = f'{int(time())}'
    time_stamped_token = f'{API_TOKEN}:{timestamp}'.encode('utf-8')

    # Get hased API token
    hashed_token = sha256(time_stamped_token).hexdigest()
    authentication = f'{USER_ID}:{hashed_token}'.encode('utf-8')
    authentication = b64encode(authentication).decode('ascii')

    # Create headers dictionary.
    return {
        'Authorization': f'Basic {authentication}',
        'Timestamp': timestamp
    }

# Authenticate to verify credentials
response = post(f'{BASE_URL}/authenticate', headers = get_headers())
print(response.json())

# --------------------

# The project ID of the project to compile
project_id = 12345678

### Create Compilation Job
# Prepare data payload to create a compilation job
payload = {
    "projectId": project_id  # ID of the project to compile
}
# Send a POST request to the /compile/create endpoint to start compilation
response = post(f'{BASE_URL}/compile/create', headers=get_headers(), json=payload)
# Parse the JSON response into python managable dict
result = response.json()
# Extract the compile ID from the response
compile_id = result['compileId']
# Check if the request was successful and print the result
if result['success']:
    print("Compilation Job Created Successfully:")
    print(result)

### Read Compilation Result
# Prepare data payload to read compilation result
payload = {
    "projectId": project_id,  # ID of the project
    "compileId": compile_id  # ID of the compilation job
}
# Send a POST request to the /compile/read endpoint to get compilation result
response = post(f'{BASE_URL}/compile/read', headers=get_headers(), json=payload)
# Parse the JSON response into python managable dict
result = response.json()
# Check if the request was successful and print the result
if result['success']:
    print("Compilation Result:")
    print(result)
```
