> ## Documentation Index
> Fetch the complete documentation index at: https://partners.usehammock.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Errors

> Every error has a type, a stable code and the parameter at fault.

Hammock uses standard HTTP status codes, and every error response has the same body.

```json theme={null}
{
  "error": {
    "type": "invalid_request_error",
    "code": "parameter_invalid",
    "message": "employee_amount must be zero or greater.",
    "param": "deductions[0].employee_amount",
    "doc_url": "https://docs.usehammock.co/api/errors#parameter_invalid",
    "request_id": "req_9Kd2Lm5nPq8R"
  }
}
```

| Field | Meaning |
| - | - |
| `type` | The category of error. Always present. |
| `code` | A short, stable string for the specific error. Branch on this. |
| `message` | An explanation for developers. Don't parse it or show it to end users: wording can change. |
| `param` | The parameter at fault, when there is one. Nested fields use dots and brackets. |
| `doc_url` | A link to this page's entry for the code. |
| `request_id` | The same value as the `Request-Id` header. |

## Types

| Type | Meaning |
| - | - |
| `invalid_request_error` | The request is wrong for the current state. Fix it before retrying. |
| `idempotency_error` | An `Idempotency-Key` was reused with a different request. |
| `api_error` | Something went wrong at Hammock. These are rare, and safe to retry with the same idempotency key. |

## HTTP statuses

| Status | Meaning |
| - | - |
| `200` | The request succeeded. |
| `400` | The request was invalid, or not allowed in the object's current state. |
| `401` | The API key is missing or invalid. |
| `403` | The key can't do this, such as a test helper called with a live key. |
| `404` | The object doesn't exist, or isn't yours. |
| `409` | The request conflicts with another, such as a duplicate `external_id`. |
| `429` | Too many requests. |
| `500`, `502`, `503`, `504` | Something went wrong at Hammock. |

## Codes

### Requests and parameters

| Code | Status | Meaning |
| - | - | - |
| `parameter_missing` | 400 | A required parameter wasn't sent. |
| `parameter_invalid` | 400 | A parameter has the wrong type, format or value. |
| `parameter_unknown` | 400 | A parameter isn't recognized. Check for a typo. |
| `resource_missing` | 404 | No object with that ID exists for you. |
| `external_id_taken` | 409 | Another object already has that `external_id`. |
| `version_invalid` | 400 | The `Hammock-Version` header isn't a known version. |

### Authentication and limits

| Code | Status | Meaning |
| - | - | - |
| `api_key_invalid` | 401 | The key is missing, malformed or revoked. |
| `test_helper_unavailable` | 403 | Test helpers only work in the sandbox. |
| `rate_limit` | 429 | Too many requests. Wait for `Retry-After` seconds. |
| `idempotency_key_reused` | 400 | The key was used before with different parameters. |
| `idempotency_request_in_progress` | 409 | A request with this key is still running. Retry shortly. |

### Employers and employees

| Code | Status | Meaning |
| - | - | - |
| `employer_not_active` | 400 | The employer hasn't finished setup and review, or is closed. |
| `employee_terminated` | 400 | The employee is terminated, so they can't enroll. |
| `pay_schedule_frequency_locked` | 400 | Employees on the schedule have elections, so its frequency can't change. |

### Payrolls

| Code | Status | Meaning |
| - | - | - |
| `deduction_not_reportable` | 400 | The deduction belongs to another employer, or doesn't apply on the pay date. |
| `reimbursement_not_pending` | 400 | The reimbursement was already paid or canceled. |
| `contribution_limit_exceeded` | 400 | An amount would take the employee past an IRS annual limit. |
| `payroll_not_voidable` | 400 | The payroll's pull has started, or it's already voided. |

### Hammock errors

| Code | Status | Meaning |
| - | - | - |
| `internal_error` | 500 | An unexpected error. Retry with the same idempotency key. |

## Handling errors

* **Branch on `code`**, and fall back to `type` for codes you don't know. New codes can be added
  without a new API version.
* **Retry `api_error`, `429` and network failures** with exponential backoff and the same
  `Idempotency-Key`.
* **Don't retry other `invalid_request_error`s** unchanged. The same request fails the same way.
* **Log `request_id`.** It's the fastest way for us to find what happened.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.