Skip to content

POST == Create

The POST method is used to create new resources through the API.

Use the below example to create a new Site within an existing Project (id: 60)

Resource ID Numbers

Most places where the API references a relationship between resources (i.e.: the relationship between a Project and a Site), it uses a number in the id field which identifies the unique ID of the related resource.

These ID numbers can often be seen in the URL paths of the GUI.

In the case of a Project, you can find the ID number of a project in the API browser, or in the Project Settings page.

Create a new Site in Project (id: 60)
curl -s -X POST \
    -H "Authorization: Token xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
    -H "Content-Type: application/json"  \
    -d '{
            "project": 60,
            "name": "My New Site"
        }' \
    https://deploy.c1engineering.com/api/projects/sites/
Create a new Site in Project (id: 60)
$Body = @{
    project = 60
    name = "My New Site"
}
Invoke-RestMethod `
    -Method 'Post' `
    -Headers @{Authorization="Token xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"} `
    -Body $Body `
    -Uri https://deploy.c1engineering.com/api/projects/sites/
Create a new Site in Project (id: 60)
import json
import requests

response = requests.post(
    'https://deploy.c1engineering.com/api/projects/sites/',
    headers={
        'Authorization':
        'Token xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
    },
    data={
        'project': 60,
        'name': 'My New Site4'
    }
)

location = response.json()

print(json.dumps(location, indent=4))