## PATCH /api/v2/account/invoice-lead

**Update invoice timing**

Sets how many days before the due date the account's renewal invoices are created and sent. Send `days` as 7, 14 or 30. Send 0 to go back to each product's own lead: 30 days for web hosting and domains, 14 days for VPS. The value covers every service and domain renewal on the account and applies from the next renewal. Due dates do not change. The response is the setting as saved. A 503 means the change could not be confirmed. Read the setting with [`GET /api/v2/account/invoice-lead`](/endpoints/account/get-v2-account-invoice-lead/) before you retry.

### Related Endpoints

- `GET /api/v2/account/invoice-lead`: Get invoice timing
- `GET /api/v2/account/service-consolidation`: Get monthly service invoice preferences
- `PATCH /api/v2/account/service-consolidation`: Update monthly service invoice preferences

### Headers

- `Authorization`: Bearer $HOSTUP_API_KEY
- Scope: `write:billing`
- `Content-Type`: application/json

### Request Body

- `days` (integer, required): Days before the due date: 7, 14 or 30. 0 means each product's own lead.
  Allowed values: 0, 7, 14, 30

### Request Examples

#### 30 days before the due date

```bash
curl -X PATCH "https://cloud.hostup.se/api/v2/account/invoice-lead" \
  -H "Authorization: Bearer $HOSTUP_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "days": 30
  }'
```

```json
{
  "days": 30
}
```

#### Each product's own lead

```bash
curl -X PATCH "https://cloud.hostup.se/api/v2/account/invoice-lead" \
  -H "Authorization: Bearer $HOSTUP_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "days": 0
  }'
```

```json
{
  "days": 0
}
```

### Response Schema

- `days` (integer, required, nullable): Days before the due date that renewal invoices are created. `null` when each product's own lead applies.
- `source` (string, required, nullable): Who set the value: `default` (a default Hostup applies), `customer` (chosen on the account) or `staff` (set by Hostup support). `null` when no value is set.
  Allowed values: default, customer, staff
- `available` (boolean, required): `false` while the setting is temporarily unavailable.
- `actions` (object, required)
- `actions.canChange` (object, required): Whether the value can be changed now.
- `actions.canChange.allowed` (boolean, required): `true` when `PATCH /api/v2/account/invoice-lead` can change the value now.
- `actions.canChange.reason` (string, required, nullable): Why the value cannot be changed. `null` when `allowed` is `true`.

### Responses

#### 200 - The invoice timing as saved.
```json
{
  "days": 30,
  "source": "customer",
  "available": true,
  "actions": {
    "canChange": {
      "allowed": true,
      "reason": null
    }
  }
}
```

#### 400 - Send `days` as 0, 7, 14 or 30 and no other field.
```json
{
  "type": "https://developer.hostup.se/errors/invalid_request",
  "title": "Invoice timing",
  "status": 400,
  "detail": "Send days as 0 (standard), 7, 14 or 30.",
  "code": "invalid_request",
  "instance": "/api/v2/account/invoice-lead"
}
```

#### 401 - Unauthorized. Authentication is required.
```json
{
  "type": "https://developer.hostup.se/errors/unauthorized",
  "title": "Unauthorized",
  "status": 401,
  "detail": "Authentication is required.",
  "code": "unauthorized",
  "instance": "/api/v2/resource",
  "requestId": "req_01hxa3b4c5d6e7f8g9h0j1k2m3",
  "timestamp": "2026-04-27T12:34:56.000Z"
}
```

#### 403 - The API key lacks `write:billing`. A session that is not the account owner gets it too.

#### 404 - Not found. The resource does not exist or is not owned by the caller.
```json
{
  "type": "https://developer.hostup.se/errors/not_found",
  "title": "Not found",
  "status": 404,
  "detail": "The requested resource could not be found.",
  "code": "not_found",
  "instance": "/api/v2/resource",
  "requestId": "req_01hxa3b4c5d6e7f8g9h0j1k2m3",
  "timestamp": "2026-04-27T12:34:56.000Z"
}
```

#### 429 - Rate limited. Retry after the limit resets. 429 responses include `Retry-After` seconds plus `X-RateLimit-*` headers.
```json
{
  "type": "https://developer.hostup.se/errors/rate_limit_exceeded",
  "title": "Too many requests",
  "status": 429,
  "detail": "Rate limit exceeded. Please try again later.",
  "code": "rate_limit_exceeded",
  "instance": "/api/v2/resource",
  "requestId": "req_01hxa3b4c5d6e7f8g9h0j1k2m3",
  "timestamp": "2026-04-27T12:34:56.000Z"
}
```

#### 500 - Internal error. Retry later or contact support if the issue persists.
```json
{
  "type": "https://developer.hostup.se/errors/internal_error",
  "title": "Internal server error",
  "status": 500,
  "detail": "An unexpected error occurred. Retry later or contact support if the issue persists.",
  "code": "internal_error",
  "instance": "/api/v2/resource",
  "requestId": "req_01hxa3b4c5d6e7f8g9h0j1k2m3",
  "timestamp": "2026-04-27T12:34:56.000Z"
}
```

#### 503 - The change could not be confirmed. Read the setting again before you retry.
```json
{
  "type": "https://developer.hostup.se/errors/billing_state_unavailable",
  "title": "Invoice timing",
  "status": 503,
  "detail": "The invoice timing could not be confirmed. Reload the setting before trying again.",
  "code": "billing_state_unavailable",
  "instance": "/api/v2/account/invoice-lead"
}
```
