POST/ activities/
Create activity
You can create an activity. It can be linked to a contact (user_id), a deal and a company, or to none of them. Fields that aren't in the table are ignored: no attribute is created for them.
Attributes
Optional unless marked required
- custom_id
- Your own ID for the activity. Unique: another activity can't have the same one.
- activity_type
- A unique identifier of any activity type given by User automatically.
- assigned_to
- A unique identifier for the agent which is given by User automatically.
- company_id
- A unique identifier for the company which is given by User automatically.
- deal_id
- A unique identifier for the deal which is given by User automatically.
- description
- A description of the activity.
- done
- Whether the activity is done.
falsewhen not sent. - due_date
- When the activity is due, ISO 8601 (for example
2026-11-21T10:00:00Z). A date in the past is accepted. - duration
- Time needed for the activity.
15when not sent. Not checked beyond being a whole number: a negative value is accepted. - name
- The main title of the activity.
- user_id
- A unique identifier for the user which is given by User automatically.
Request
- cURL
- JavaScript
- PHP
- Python
curl -X POST "https://<your_app_subdomain>.user.com/api/public/activities/" \
-H "Authorization: Token <your_64_char_api_key>" \
-H "Accept: */*; version=2" \
-H "Content-Type: application/json" \
-d '{
"name": "Onboarding call",
"activity_type": 6,
"due_date": "2026-11-10T13:40:17Z",
"duration": 30,
"description": "Walk through the first campaign setup.",
"user_id": 1884
}'
const response = await fetch(
"https://<your_app_subdomain>.user.com/api/public/activities/",
{
method: "POST",
headers: {
Authorization: "Token <your_64_char_api_key>",
Accept: "*/*; version=2",
"Content-Type": "application/json",
},
body: JSON.stringify({
name: "Onboarding call",
activity_type: 6,
due_date: "2026-11-10T13:40:17Z",
duration: 30,
description: "Walk through the first campaign setup.",
user_id: 1884,
}),
},
);
const data = await response.json();
console.log(data);
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://<your_app_subdomain>.user.com/api/public/activities/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: Token <your_64_char_api_key>",
"Accept: */*; version=2",
"Content-Type: application/json",
],
CURLOPT_POSTFIELDS => json_encode([
"name" => "Onboarding call",
"activity_type" => 6,
"due_date" => "2026-11-10T13:40:17Z",
"duration" => 30,
"description" => "Walk through the first campaign setup.",
"user_id" => 1884,
]),
]);
$response = curl_exec($curl);
curl_close($curl);
echo $response;
import requests
response = requests.post(
"https://<your_app_subdomain>.user.com/api/public/activities/",
headers={
"Authorization": "Token <your_64_char_api_key>",
"Accept": "*/*; version=2",
},
json={
"name": "Onboarding call",
"activity_type": 6,
"due_date": "2026-11-10T13:40:17Z",
"duration": 30,
"description": "Walk through the first campaign setup.",
"user_id": 1884,
},
)
print(response.json())
Response examples
- 201 Created
- 400 Bad Request
{
"id": 14,
"activity_type": 6,
"name": "Onboarding call",
"due_date": "2026-11-10T13:40:17Z",
"duration": 30,
"description": "Walk through the first campaign setup.",
"assigned_to": null,
"deal_id": null,
"user_id": 1884,
"company_id": null,
"done": false,
"done_date": null,
"created_by": 1,
"created_at": "2026-11-09T13:40:18.141486Z",
"updated_at": "2026-11-09T13:40:18.141509Z",
"custom_id": null
}
{"activity_type": ["Incorrect type. Expected pk value, received str."]}A 400 names every field that was rejected, each with its messages. The ones you're most likely to see:
| Message | When |
|---|---|
This field is required. | name, activity_type or due_date is missing (each missing field is listed). |
Invalid pk "123" - object does not exist. | No record has that ID: activity_type, assigned_to (agent), user_id, deal_id or company_id. |
Incorrect type. Expected pk value, received str. | An ID field got a string. |
Datetime has wrong format. Use one of these formats instead: YYYY-MM-DDThh:mm[:ss[.uuuuuu]][+HH:MM|-HH:MM|Z]. | due_date isn't an ISO 8601 date and time. |
A valid integer is required. | duration isn't a whole number. |
Must be a valid boolean. | done isn't true or false. |
activity with this custom id already exists. | Another activity already has that custom_id. |
Response fields
Fields returned in the 201 Created response body.
- id
- A unique identifier for the activity which is given by User automatically.
- activity_type
- A unique identifier of any activity type given by User automatically.
- name
- An activity name.
- due_date
- When the activity is due, ISO 8601 (for example
2026-11-21T10:00:00Z). A date in the past is accepted. - duration
- Time needed for the activity.
15when not sent. Not checked beyond being a whole number: a negative value is accepted. - description
- A description of the activity.
- assigned_to
- A unique identifier for the agent which is given by User automatically.
- deal_id
- A unique identifier for the deal which is given by User automatically.
- user_id
- ID of the contact the activity is linked to.
nullwhen there's none, also after the contact is deleted. - company_id
- A unique identifier for the company which is given by User automatically.
- done
- Whether the activity is done.
falsewhen not sent. - done_date
- When the activity was marked as done: set when
donebecomestrue, cleared when it becomesfalse. Read-only. - created_by
- A unique identifier of an agent who created an activity.
- created_at
- A creation date of an activity.
- updated_at
- A date of last activity update.
- custom_id
- Your own ID for the activity. Unique: another activity can't have the same one.
note
Errors that can come from any endpoint (401, 429, 500, 502, 504) are described in HTTP response codes.