# POST /api/v2/checkins

Check in

- MCP id: checkins.store
- Scope: api:write:checkins
- Permission: none, the record's own rules still apply
- Rate cost: 1 unit, write bucket. A write costs the same whatever `view` you ask for.
- Cache-Control: private, no-store

Opens a checkin for the authenticated user and returns it with a `Location` header.

`user_id` is not accepted: a checkin always belongs to the caller, and sending the key is a `422`; there is no way to check another employee in, just as there is none in plnnrly. Omit `checked_in_at` to clock in now. Send `checked_out_at` as well to record an already-finished period in one call, which is what a backfill client does. Nothing rejects a second still-open checkin: plnnrly hides its check-in button while one is open, but this endpoint answers `201` either way, so check `filter[checked_out_at][null]=true` first if you need that guarantee. This operation declares no permission of its own, but checking in still requires `checkins::read`, so unlike the check-in button in plnnrly, this endpoint is not open to every employee.

## Parameters
- view (string, optional): Which field set to render.
- X-Request-Id (header, optional): A correlation id of your own. It is recorded in our logs next to the server's request id but never returned: the response header always carries the server's id. A value that does not match the pattern is discarded silently, never rejected.
- Idempotency-Key (header, optional): A caller-chosen key that makes this POST safe to retry. Replaying it returns the original response with Idempotency-Replayed: true.

## Request body
- checked_in_at (timestamp (YYYY-MM-DDThh:mm:ssZ), optional): When the employee clocked in.
- checked_out_at (timestamp (YYYY-MM-DDThh:mm:ssZ) or null, optional): When the employee clocked out, or `null` while the checkin is still open. A `null` value marks the checkin plnnrly shows as active. Must be on or after checked_in_at.

Unknown keys are refused with `422` validation-failed, naming the key.

## Response 201
- id (integer, required): Unique identifier.
- user_id (integer, required, server-assigned): Employee this checkin belongs to. Assigned from the authenticated user on create and never writable.
- user (Ref or UserSummary, required): The employee this checkin belongs to. Expanding it with `?include=user` additionally requires the `users::read` permission and a token scope covering the users prefix.
- checked_in_at (timestamp (YYYY-MM-DDThh:mm:ssZ), required): When the employee clocked in.
- checked_out_at (timestamp (YYYY-MM-DDThh:mm:ssZ) or null, required): When the employee clocked out, or `null` while the checkin is still open. A `null` value marks the checkin plnnrly shows as active.
- created_at (timestamp (YYYY-MM-DDThh:mm:ssZ), required): Creation timestamp.
- updated_at (timestamp (YYYY-MM-DDThh:mm:ssZ), required): Last-write timestamp; use for incremental sync.
- links (CheckinLinks, required)
  - self (url, required): The canonical URI of this record.

## Errors
- 403 forbidden-by-policy | insufficient-permission | insufficient-token-scope: Forbidden.
- 409 idempotency-key-in-flight | idempotency-key-reused: Conflict.
- 415 unsupported-media-type: Unsupported media type.
- 422 unprocessable-relationship | validation-failed: Unprocessable content.
- 400 idempotency-key-required | invalid-cursor | invalid-query-parameter | malformed-request | unsupported-parameter: Bad request.
- 401 token-expired | unauthenticated: Unauthenticated.
- 404 endpoint-not-found | resource-not-found: Not found.
- 406 not-acceptable: Not acceptable.
- 429 rate-limit-exceeded: Too many requests.
- 500 internal-error: Server error.
- 503 tenant-unavailable: Service unavailable.

## Example
```bash
curl -X POST \
  'https://<your-url>/api/v2/checkins' \
  -H 'Authorization: Bearer <token>' \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  -H 'Idempotency-Key: <key>' \
  -d '{}'
```
