Writes and idempotency
Creating and updating time entries and clients safely.
What you can write
| Endpoint | Scope | Notes |
|---|---|---|
POST /v1/time-entries | time_entries.write | Draft or Awaiting Review; never Approved |
PATCH /v1/time-entries/{id} | time_entries.write | Approved entries are locked |
POST /v1/clients | clients.write | You choose the clientId slug |
PATCH /v1/clients/{id} | clients.write | Slug or UUID in the path |
Deleting, approving, rejecting, and billing stay in the app for now.
Who is the actor?
Writes run the same rules as the Pulse app, so they need to know who is acting.
| Credential | Time entries | Clients |
|---|---|---|
API key (pulse_sk_…) | POST requires userId: the team member whose time it is. PATCH acts as the entry's owner. | The organization acts for itself. |
| OAuth client-credentials token | Same as an API key. | Same as an API key. |
| OAuth user-delegated token | Acts as the authorizing user. A userId that disagrees is a 400. | Acts as the authorizing user, with their client-team access. |
The credential's scope gates the endpoint; the user's permissions gate the action. If the team member cannot log time in the app, the API returns 403 even though your key holds time_entries.write.
Rules you will hit
Business-rule failures return 422 with error.code = "unprocessable" and the same message the app shows: locked dates and weeks, weekly hour caps, approved entries, missing task selection, exceeded budgets, inactive clients. Fix the cause and retry.
PATCH semantics
PATCH is a JSON merge. Omitted fields are unchanged; null clears a nullable field. Bodies are strict: an unknown field returns 400 and names the field in the error message, so typos never silently do nothing. Send at least one field. If you lower hours without sending billableHours, the existing billableHours is clamped to the new hours by the same rule the app applies; send both to control the result.
Idempotency-Key
Add an Idempotency-Key header (1–255 characters, unique per logical operation) to any POST or PATCH. Recommended for every POST.
- Repeating the same key with the same body returns the stored
2xxresponse and the headerIdempotent-Replayed: true. No second write happens. - Repeating the key with a different body returns
422idempotency_error. - Repeating the key while the first request is still running returns
409conflictwithRetry-After: 1. - Only successful responses are stored. If a write fails, the key is released so you can fix the payload and retry with the same key.
- Keys are scoped to your credential, the HTTP method, and the path, and expire after 24 hours.
- If the idempotency store is unavailable and you sent a key, the request fails closed with
503service_unavailableandRetry-After. Requests without a key are unaffected.
Limits and status codes
Bodies are capped at 64 KB (413). Writes share your credential's rate limit (see Rate limits).
| Status | error.code | Meaning |
|---|---|---|
201 / 200 | — | Created / updated; body is the same DTO GET returns, Location on 201 |
400 | invalid_request | Validation, unknown field, empty patch, bad userId |
403 | forbidden | Missing scope, or the acting user lacks the permission |
404 | not_found | No such entry or client in your organization |
409 | conflict | Duplicate clientId, or an identical request is in flight |
413 | invalid_request | Body over 64 KB |
422 | unprocessable | A business rule blocked the write |
422 | idempotency_error | Key reused with a different body |
503 | service_unavailable | Idempotency store unavailable; retry with the same key |