Activate a User with the REST API v2
This endpoint flips an INACTIVE user back to ACTIVE so the person can sign in and submit leave requests again. It requires the users:write scope, takes no request body, and returns either a completed user record or an asynchronous operation to poll. Activation also consumes a subscription seat, which is the most common reason the call fails.
What the endpoint does
A successful activation restores the user's ability to authenticate and request leave. The caller must be an admin, or a location admin who manages that user; the same rule applies to the user identified by X-On-Behalf-Of. The endpoint waits for the change and returns the updated user with status ACTIVE and HTTP 200, or returns 202 Accepted with an operation object to poll. No request body is needed.
Request shape and controls
The route is POST /v2/users/{id}/activate. The id path parameter is a required string identifying the user. Two optional headers matter: Idempotency-Key makes the write safe to retry, and X-On-Behalf-Of names the user the write is performed for. The Authorization header carries the API key as a Bearer token. The complete request contract, including the exact curl example and SDK variants, is delivered in the protected code and schema modules referenced below.
Seat limits and remediation
Activation takes a seat on the company's subscription. When no seat is free, the endpoint fails with 409 USER_SEAT_LIMIT_REACHED. To recover, either deactivate another user to free a seat or add seats in the dashboard, then retry the activation. This is a state conflict, not a permission problem, so retrying without changing seat availability will not succeed.
Handling 200 vs 202
When the change completes within the request, the response body contains the user object with status ACTIVE. When the write is still running, the response is 202 with an operation object containing id, status, and url. Poll the operation URL until status is SUCCEEDED or FAILED. A status of UNKNOWN means no result arrived within 15 minutes; the change may or may not have been applied, so read the user resource to check. The Location header carries the same URL as operation.url.
Failure distinction checklist
Use this checklist to route errors correctly:
- 403 ON_BEHALF_OF_NOT_ALLOWED: the X-On-Behalf-Of user is not permitted; check the users:act-on-behalf scope and whether the key owner manages the target user.
- 403 FORBIDDEN: the key owner lacks the admin or location-admin role needed for this user.
- 404 RESOURCE_NOT_FOUND: the user does not exist or is outside the key's data reach.
- 409 USER_SEAT_LIMIT_REACHED: free a seat or add seats, then retry.
- 409 IDEMPOTENCY_REQUEST_IN_PROGRESS: the first request with this key is still running; wait before retrying.
- 422 IDEMPOTENCY_KEY_REUSED: the key was used with a different request; use a new key.
- 400 INVALID_IDEMPOTENCY_KEY: the key is not 1 to 255 printable ASCII characters.
Idempotent retries
Attach an Idempotency-Key header when you want a retried activation to be harmless. Each key is scoped to one API key and kept for 24 hours. If you resend the identical request with that same key inside the window, you get the stored first response back rather than a second activation, and the reply carries the Idempotent-Replayed header. Three things can go wrong instead: pointing the key at a different request yields 422 IDEMPOTENCY_KEY_REUSED; sending it again while the original is still executing yields 409 IDEMPOTENCY_REQUEST_IN_PROGRESS; and a key that is not 1 to 255 printable ASCII characters yields 400 INVALID_IDEMPOTENCY_KEY. In short, one key belongs to one request, and a retry should wait for the first attempt to finish.
Field and control map
Path: id (required string, resource ID). Headers: Authorization (Bearer token), Idempotency-Key (optional, 1-255 printable ASCII), X-On-Behalf-Of (optional user ID). Response 200: data object with id, name, email, isAdmin, locationId, departmentId, status, employeeId, startDate, endDate, labels, and optional expanded location, department, and holidays. Response 202: operation object with id, status (PENDING, SUCCEEDED, FAILED, UNKNOWN), and url. Error envelope: error.code, error.name, error.description, error.resolution, error.requestId, and optional details.
| Status | Body | Action |
|---|---|---|
| 200 | User object with status ACTIVE | Done; read the user fields as needed |
| 202 | Operation object with id, status, url | Poll operation.url until SUCCEEDED or FAILED |
| 202 with UNKNOWN | Operation status UNKNOWN | Read the user resource to check whether the change applied |
| 409 USER_SEAT_LIMIT_REACHED | Error envelope | Free a seat or add seats, then retry |
| 403 ON_BEHALF_OF_NOT_ALLOWED | Error envelope | Check users:act-on-behalf scope and management relationship |
| 404 RESOURCE_NOT_FOUND | Error envelope | Verify the user ID and the key's data reach |
Status codes and error codes are taken from the endpoint contract; no runtime execution was performed.
| Situation | Result | Next step |
|---|---|---|
| Same key, same request, within 24 hours | Original response replayed with Idempotent-Replayed header | Treat as the original result; do not re-send as a new write |
| Same key, different request | 422 IDEMPOTENCY_KEY_REUSED | Generate a new key for the new request |
| Same key, first request still running | 409 IDEMPOTENCY_REQUEST_IN_PROGRESS | Wait for the first attempt, then retry with the same key |
| Key outside 1-255 printable ASCII | 400 INVALID_IDEMPOTENCY_KEY | Fix the key format before retrying |
Outcomes reflect the documented header contract; no live retry behavior was executed.
Frequently asked questions
Does activation require a request body?
No. The endpoint takes no request body. The only inputs are the id path parameter, the Authorization header, and the optional Idempotency-Key and X-On-Behalf-Of headers.
What happens if the company has no free seats?
The request fails with 409 USER_SEAT_LIMIT_REACHED. Free a seat by deactivating another user or add seats in the dashboard, then retry.
Can I retry safely after a timeout?
Yes, if you send the same Idempotency-Key with the same request within 24 hours. The original response is replayed with the Idempotent-Replayed header. A different request with the same key returns 422 IDEMPOTENCY_KEY_REUSED.
What does an operation status of UNKNOWN mean?
UNKNOWN means no result arrived within 15 minutes. The change may or may not have been applied, so read the user resource to check. A result that arrives later still changes the status to SUCCEEDED or FAILED.
Who can activate a user?
The key owner, or the X-On-Behalf-Of user, must be an admin or a location admin who manages the target user. The key also needs the users:write scope.
curl -X POST "$API_BASE_URL/v2/users/string/activate" \
-H "Authorization: Bearer "{
"data": {
"id": "user-cfe5d39b-f1f0-45aa-85cd-ce93e637a262",
"name": "John Chao",
"email": "[email protected]",
"isAdmin": false,
"locationId": "location-79c77ac8-e5bf-479f-9488-648a58379ff1",
"departmentId": "team-0a21c25e-6925-4a5b-90ee-ecf82096c4f6",
"status": "ACTIVE",
"employeeId": "E-1024",
"startDate": "2022-11-08",
"endDate": null,
"labels": [
{
"id": "969f8429-7dc3-48a1-96b1-6049a99dda06",
"name": "contractor",
"color": "#FF0000"
}
]
}
}{
"operation": {
"id": "pa_3f1c2b9e-8a47-4d5e-9c61-2b7f0e4a1d93",
"status": "PENDING",
"url": "/v2/operations/pa_3f1c2b9e-8a47-4d5e-9c61-2b7f0e4a1d93"
}
}{
"error": {
"code": "VALIDATION_ERROR",
"name": "ValidationError",
"description": "Example post details.",
"resolution": "Fix the fields listed in details.fields and send the request again.",
"requestId": "c6af9ac6-7b61-11e6-9a41-93e8deadbeef",
"details": {
"fields": [
{
"path": "startDate",
"message": "\"startDate\" is required"
}
]
}
}
}{
"error": {
"code": "UNAUTHORIZED",
"name": "Unauthorized",
"description": "Example post details.",
"resolution": "Send a valid API key in the Authorization header as Bearer followed by the full vt_live_ key.",
"requestId": "c6af9ac6-7b61-11e6-9a41-93e8deadbeef"
}
}{
"error": {
"code": "INSUFFICIENT_SCOPE",
"name": "InsufficientScope",
"description": "Example post details.",
"resolution": "Add the scopes listed in details.requiredScopes to the key in the OnlyLeave dashboard.",
"requestId": "c6af9ac6-7b61-11e6-9a41-93e8deadbeef",
"details": {
"requiredScopes": [
"leaves:write"
]
}
}
}{
"error": {
"code": "RESOURCE_NOT_FOUND",
"name": "ResourceNotFound",
"description": "Example post details.",
"resolution": "Check the ID of the resource named in details.resource and that the key owner can see it.",
"requestId": "c6af9ac6-7b61-11e6-9a41-93e8deadbeef"
}
}{
"error": {
"code": "CONFLICT",
"name": "Conflict",
"description": "Example post details.",
"resolution": "Read the resource again and retry with up-to-date values.",
"requestId": "c6af9ac6-7b61-11e6-9a41-93e8deadbeef"
}
}{
"error": {
"code": "LEAVE_NEGATIVE_BALANCE",
"name": "LeaveNegativeBalance",
"description": "Example post details.",
"resolution": "Shorten the leave, use a different leave type, or ask an admin to adjust the quota.",
"requestId": "c6af9ac6-7b61-11e6-9a41-93e8deadbeef"
}
}{
"error": {
"code": "RATE_LIMITED",
"name": "RateLimited",
"description": "Example post details.",
"resolution": "Wait a few seconds and retry, using the same Idempotency-Key for writes.",
"requestId": "c6af9ac6-7b61-11e6-9a41-93e8deadbeef"
}
}{
"error": {
"code": "INTERNAL_ERROR",
"name": "InternalError",
"description": "Example post details.",
"resolution": "Retry later, and if it keeps happening, contact OnlyLeave support and quote the requestId.",
"requestId": "c6af9ac6-7b61-11e6-9a41-93e8deadbeef"
}
}id
| Field | Type | Required | Description | Constraints |
|---|---|---|---|---|
| id | string | Yes | resource ID. |
Idempotency-Key
| Field | Type | Required | Description | Constraints |
|---|---|---|---|---|
| Idempotency-Key | string | No | optional key (1 to 255 printable ASCII characters) that makes a write request safe to retry. Keys are retained for 24 hours per API key. Retrying with the same key and the same request within those 24 hours replays the original response (with the Idempotent-Replayed header). Reusing the key with a different request returns 422 IDEMPOTENCY_KEY_REUSED ; retrying while the first request is still running returns 409 IDEMPOTENCY_REQUEST_IN_PROGRESS ; an invalid key returns 400 INVALID_IDEMPOTENCY_KEY . | 1 <= length <= 255 |
X-On-Behalf-Of
| Field | Type | Required | Description | Constraints |
|---|---|---|---|---|
| X-On-Behalf-Of | string | No | ID of the user the write is performed for. Requires the users:act-on-behalf scope, and the key owner must manage the target user; otherwise the request fails with 403 ON_BEHALF_OF_NOT_ALLOWED . Ignored on GET requests. |
response
| Field | Type | Required | Description | Constraints |
|---|---|---|---|---|
| response | object | |||
| response.data | object | No | ||
| response.data.id | string | Yes | user ID | |
| response.data.name | string | Yes | user name | |
| response.data.email | string | Yes | user email | |
| response.data.isAdmin | boolean | Yes | a boolean that tells you if the selected user is an admin | |
| response.data.locationId | string | null | Yes | the ID of the user's location, null when the user has none yet | |
| response.data.locationId[variant1] | string | the ID of the user's location, null when the user has none yet | ||
| response.data.locationId[variant2] | null | the ID of the user's location, null when the user has none yet | ||
| response.data.departmentId | string | null | Yes | the ID of the user's department, null when the user has none yet | |
| response.data.departmentId[variant1] | string | the ID of the user's department, null when the user has none yet | ||
| response.data.departmentId[variant2] | null | the ID of the user's department, null when the user has none yet | ||
| response.data.status | string | Yes | user status | "ACTIVE" | "INACTIVE" | "DELETED" |
| response.data.employeeId | string | null | Yes | the employee ID set on the user profile page, null when it is not set | |
| response.data.employeeId[variant1] | string | the employee ID set on the user profile page, null when it is not set | ||
| response.data.employeeId[variant2] | null | the employee ID set on the user profile page, null when it is not set | ||
| response.data.startDate | string | null | Yes | employment start date as stored, an ISO 8601 date or timestamp (the same value v1 returns), null when it is not set | |
| response.data.startDate[variant1] | string | employment start date as stored, an ISO 8601 date or timestamp (the same value v1 returns), null when it is not set | ||
| response.data.startDate[variant2] | null | employment start date as stored, an ISO 8601 date or timestamp (the same value v1 returns), null when it is not set | ||
| response.data.endDate | string | null | Yes | employment end date as stored, an ISO 8601 date or timestamp (the same value v1 returns), null when it is not set | |
| response.data.endDate[variant1] | string | employment end date as stored, an ISO 8601 date or timestamp (the same value v1 returns), null when it is not set | ||
| response.data.endDate[variant2] | null | employment end date as stored, an ISO 8601 date or timestamp (the same value v1 returns), null when it is not set | ||
| response.data.labels | array<object> | Yes | labels assigned to the user | |
| response.data.labels[] | object | |||
| response.data.labels[].id | string | Yes | ||
| response.data.labels[].name | string | Yes | ||
| response.data.labels[].color | string | Yes | ||
| response.data.location | object | No | the user's location (only when expand includes location) | |
| response.data.location.id | string | Yes | location ID | |
| response.data.location.name | string | Yes | location name | |
| response.data.location.timezone | string | No | the location's IANA time zone, left out when none is stored | |
| response.data.location.isDefault | boolean | Yes | whether this is the company's default location | |
| response.data.location.createdAt | string | Yes | a timestamp in the ISO 8601 format | date-time |
| response.data.department | object | No | the user's department (only when expand includes department) | |
| response.data.department.id | string | Yes | department ID | |
| response.data.department.name | string | Yes | department name | |
| response.data.department.isDefault | boolean | Yes | whether this is the company's default department | |
| response.data.department.createdAt | string | Yes | a timestamp in the ISO 8601 format | date-time |
| response.data.holidays | array<HolidayYear> | No | public holidays for the user's location, grouped by year (only when expand includes holidays) | |
| response.data.holidays[] | object | |||
| response.data.holidays[].year | integer | No | the year for the holidays | |
| response.data.holidays[].holidays | array<object> | No | ||
| response.data.holidays[].holidays[] | object | |||
| response.data.holidays[].holidays[].id | string | No | holiday ID | |
| response.data.holidays[].holidays[].name | string | No | holiday name | |
| response.data.holidays[].holidays[].date | string | No | date in YYYY-MM-DD format | date |
| response.data.holidays[].holidays[].isHalfDay | boolean | No | whether it is a half-day holiday |
response
| Field | Type | Required | Description | Constraints |
|---|---|---|---|---|
| response | object | Returned with HTTP 202 when a write operation is still running, or succeeded but its result could not be read back yet. The Location header carries the same URL as operation.url . Poll it until the status is SUCCEEDED or FAILED . | ||
| response.operation | object | Yes | ||
| response.operation.id | string | Yes | ||
| response.operation.status | string | Yes | operation status. UNKNOWN means no result arrived within 15 minutes; the change may or may not have been applied, so read the resource to check. A result that arrives later still changes it to SUCCEEDED or FAILED. | Allowed values: "PENDING" | "SUCCEEDED" | "FAILED" | "UNKNOWN" |
| response.operation.url | string | Yes |
response
| Field | Type | Required | Description | Constraints |
|---|---|---|---|---|
| response | object | Error envelope returned by every endpoint, including authentication and rate limit errors. error.code is one of the codes in x-error-catalog . | ||
| response.error | object | Yes | ||
| response.error.code | string | Yes | stable machine-readable error code | |
| response.error.name | string | Yes | short human-readable error name | |
| response.error.description | string | Yes | what went wrong | |
| response.error.resolution | string | Yes | how to fix the problem | |
| response.error.requestId | string | Yes | request ID, include it when contacting support | |
| response.error.details | object | No | optional additional information specific to the error code | |
| response.error.details.[key: string] | any | No |
response
| Field | Type | Required | Description | Constraints |
|---|---|---|---|---|
| response | object | Error envelope returned by every endpoint, including authentication and rate limit errors. error.code is one of the codes in x-error-catalog . | ||
| response.error | object | Yes | ||
| response.error.code | string | Yes | stable machine-readable error code | |
| response.error.name | string | Yes | short human-readable error name | |
| response.error.description | string | Yes | what went wrong | |
| response.error.resolution | string | Yes | how to fix the problem | |
| response.error.requestId | string | Yes | request ID, include it when contacting support | |
| response.error.details | object | No | optional additional information specific to the error code | |
| response.error.details.[key: string] | any | No |
response
| Field | Type | Required | Description | Constraints |
|---|---|---|---|---|
| response | object | Error envelope returned by every endpoint, including authentication and rate limit errors. error.code is one of the codes in x-error-catalog . | ||
| response.error | object | Yes | ||
| response.error.code | string | Yes | stable machine-readable error code | |
| response.error.name | string | Yes | short human-readable error name | |
| response.error.description | string | Yes | what went wrong | |
| response.error.resolution | string | Yes | how to fix the problem | |
| response.error.requestId | string | Yes | request ID, include it when contacting support | |
| response.error.details | object | No | optional additional information specific to the error code | |
| response.error.details.[key: string] | any | No |
response
| Field | Type | Required | Description | Constraints |
|---|---|---|---|---|
| response | object | Error envelope returned by every endpoint, including authentication and rate limit errors. error.code is one of the codes in x-error-catalog . | ||
| response.error | object | Yes | ||
| response.error.code | string | Yes | stable machine-readable error code | |
| response.error.name | string | Yes | short human-readable error name | |
| response.error.description | string | Yes | what went wrong | |
| response.error.resolution | string | Yes | how to fix the problem | |
| response.error.requestId | string | Yes | request ID, include it when contacting support | |
| response.error.details | object | No | optional additional information specific to the error code | |
| response.error.details.[key: string] | any | No |
response
| Field | Type | Required | Description | Constraints |
|---|---|---|---|---|
| response | object | Error envelope returned by every endpoint, including authentication and rate limit errors. error.code is one of the codes in x-error-catalog . | ||
| response.error | object | Yes | ||
| response.error.code | string | Yes | stable machine-readable error code | |
| response.error.name | string | Yes | short human-readable error name | |
| response.error.description | string | Yes | what went wrong | |
| response.error.resolution | string | Yes | how to fix the problem | |
| response.error.requestId | string | Yes | request ID, include it when contacting support | |
| response.error.details | object | No | optional additional information specific to the error code | |
| response.error.details.[key: string] | any | No |
response
| Field | Type | Required | Description | Constraints |
|---|---|---|---|---|
| response | object | Error envelope returned by every endpoint, including authentication and rate limit errors. error.code is one of the codes in x-error-catalog . | ||
| response.error | object | Yes | ||
| response.error.code | string | Yes | stable machine-readable error code | |
| response.error.name | string | Yes | short human-readable error name | |
| response.error.description | string | Yes | what went wrong | |
| response.error.resolution | string | Yes | how to fix the problem | |
| response.error.requestId | string | Yes | request ID, include it when contacting support | |
| response.error.details | object | No | optional additional information specific to the error code | |
| response.error.details.[key: string] | any | No |
response
| Field | Type | Required | Description | Constraints |
|---|---|---|---|---|
| response | object | Error envelope returned by every endpoint, including authentication and rate limit errors. error.code is one of the codes in x-error-catalog . | ||
| response.error | object | Yes | ||
| response.error.code | string | Yes | stable machine-readable error code | |
| response.error.name | string | Yes | short human-readable error name | |
| response.error.description | string | Yes | what went wrong | |
| response.error.resolution | string | Yes | how to fix the problem | |
| response.error.requestId | string | Yes | request ID, include it when contacting support | |
| response.error.details | object | No | optional additional information specific to the error code | |
| response.error.details.[key: string] | any | No |
response
| Field | Type | Required | Description | Constraints |
|---|---|---|---|---|
| response | object | Error envelope returned by every endpoint, including authentication and rate limit errors. error.code is one of the codes in x-error-catalog . | ||
| response.error | object | Yes | ||
| response.error.code | string | Yes | stable machine-readable error code | |
| response.error.name | string | Yes | short human-readable error name | |
| response.error.description | string | Yes | what went wrong | |
| response.error.resolution | string | Yes | how to fix the problem | |
| response.error.requestId | string | Yes | request ID, include it when contacting support | |
| response.error.details | object | No | optional additional information specific to the error code | |
| response.error.details.[key: string] | any | No |