Skip to content

Create User Assignments

This endpoint adds direct project and task assignments to a user. Existing assignments are kept.

POST /v1/user-assignments/user-assignments

Include your API key in the x-api-key header. See Authentication.

user-assignments:write
FieldTypeRequiredDescription
userIdstringYesUser who receives the assignments.
projectAssignmentsstring[]YesProject IDs to assign. Send [] if you are only adding tasks. If it is missing, the API returns 500.
taskAssignments{ projectId: string; taskId: string }[]YesTasks to assign. Send [] if you are only adding projects. If it is missing, the API returns 500.

At least one of projectAssignments or taskAssignments must contain an item.

{
"userId": "user-a",
"projectAssignments": ["project-mno123pqr4567890"],
"taskAssignments": [
{
"projectId": "project-mno123pqr4567890",
"taskId": "task-pqr123stu4567890"
}
]
}
Terminal window
curl -X POST "https://api.crewsum.com/v1/user-assignments/user-assignments" \
-H "x-api-key: $CREWSUM_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"userId": "user-a",
"projectAssignments": ["project-mno123pqr4567890"],
"taskAssignments": [
{
"projectId": "project-mno123pqr4567890",
"taskId": "task-pqr123stu4567890"
}
]
}'

On success, the API returns HTTP 201 Created.

{
"message": "Successfully created user assignments for user-a",
"data": {
"userId": "user-a"
}
}
  • The operation adds assignments. It does not remove the user’s existing assignments. To replace them, use Update User Assignments.
  • For each project you assign, Crewsum also assigns that project’s default task when the task is active.
  • Each task’s projectId must be a project the user already has as a direct assignment or a project in projectAssignments. Projects the user receives only through a user group do not count. Otherwise, the API returns 500.
  • Assigning a project or task the user already has directly returns 500. Send only new assignments.
  • The request is not all-or-nothing. Crewsum saves the project assignments first and the task assignments second. If the task step fails, the project assignments are kept.
  • Every project in projectAssignments must exist in your account, and every task must exist under the projectId you send with it. Otherwise, the API returns 400 and nothing is saved.
  • The user must exist. Otherwise, the API returns 500.
  • The response echoes userId exactly as you sent it.
StatusMeaning
400"At least one assignment must be supplied": both arrays were empty.
400"Project or task not found for assignment": a project does not exist in your account, or a task does not exist under the projectId sent with it. Nothing is saved.
500"Error creating user assignments for <userId>": the request failed, for example because of a duplicate assignment, an unknown user, or a task whose project is not assigned to the user.
500A missing projectAssignments or taskAssignments returns Fastify’s default error body: { "statusCode": 500, "error": "Internal Server Error", "message": "..." }.

Authentication and scope failures are described in Errors.

This endpoint does not trigger a webhook.