# Set day goals
URL: https://docs.fluenta.io/en/docs/reference/program/set-day-goals
Operation: `setDayGoals`
Required permission: `program`

`PUT /v1/external/organizations/{organizationId}/modules/{moduleId}/days/{day}/references/{referenceId}/goal`

«Metas del día»: one referencia’s hourly goal for one day of a módulo, one rate all day or rates by minute. Answers the módulo’s day as `getHoursBoard` does.

### Authorization

- `apiToken` — Bearer token. An API token created in Configuración › Tokens de API, or a connected app’s access token

Send it as `Authorization: Bearer <your API token>`.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `moduleId` | path | integer | yes |  |
| `day` | path | string (date) | yes | A plant day, `YYYY-MM-DD`, on the organization’s clock: today or a past day, never a future one. |
| `referenceId` | path | integer | yes |  |
| `Idempotency-Key` | header | string | no | A fresh unique string per intended write (1 to 255 visible ASCII characters). Sent again unchanged only to retry THAT write after a timeout or a 409 `IDEMPOTENCY_IN_PROGRESS`: the stored answer comes back (`Idempotency-Replayed: true`) and nothing is written twice. The same key with another request is a 422 `IDEMPOTENCY_KEY_REUSED`. |
| `organizationId` | path | integer | yes | The organization, from `getMe` or `listOrganizations`. |

### Request body

`application/json`

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `goal` | integer, 1–100000 | yes | Units per hour in force at the close of the day (the last rate’s when there are `steps`). Equal to the referencia’s own «Meta por hora» with no steps, the day reads its own goal again. |
| `steps` | object[] | no | The day’s rates by minute of day, at most 48, distinct minutes. Omitted or null: one rate, `goal`, all day. |
| `steps[].from` | integer, 0–1439 | yes | Minute of the day the rate starts at (600 = 10:00). |
| `steps[].goal` | integer, 1–100000 | yes | Units per hour from then. |

### Responses

| Status | Description |
| --- | --- |
| `200` | `ExternalHoursBoardDto` |
| `400` | `INVALID_REQUEST`: a body or a parameter the route cannot take, as `{statusCode, code: 'INVALID_REQUEST', message, details}`, with one `{field, message}` in `details` per failure (`field` the body field as a path, such as `items.0.name`; null when the failure names none). Or a value the dashboard refuses (its own `code`), or `INVALID_IDEMPOTENCY_KEY`. Nothing changed. |
| `401` | Missing, malformed, unknown, expired or revoked credential: `INVALID_API_TOKEN`. |
| `402` | The organization is blocked: `ORG_BLOCKED`. |
| `403` | `ROLE_NOT_ALLOWED`: the usuario’s role does not make this change in the dashboard (it needs ADMIN, or an account with platform-wide access);`INSUFFICIENT_SCOPE`: the credential lacks «Gestionar el Programa»; `PLAN_LIMIT`: the organization’s plan does not answer this credential (a connected app needs «Conectar con IA», Plan Pro). Nothing changed. |
| `404` | The organization does not exist or is out of the credential’s reach: `ORGANIZATION_NOT_FOUND`. One body for both. |
| `409` | `IDEMPOTENCY_IN_PROGRESS` (with `Retry-After`): the same `Idempotency-Key` is still being answered; retry it unchanged. Or the dashboard’s own conflict. |
| `422` | `IDEMPOTENCY_KEY_REUSED`: the `Idempotency-Key` answered another request. Nothing changed. |
| `429` | The credential is over its rate limit: `RATE_LIMITED`. Per credential, in fixed windows of 60 seconds: 60 requests in one organization on Light and 120 on Pro; 20 on the heavy reads (the range figures, the whole floor, the month and the pauses); 300 across every organization; 60 on the routes that name no organization. Wait `Retry-After` seconds; a refused request counts against nothing. |

### Example

```bash
curl -X PUT 'https://api.fluenta.io/v1/external/organizations/{organizationId}/modules/{moduleId}/days/{day}/references/{referenceId}/goal' \
  -H 'Authorization: Bearer <your API token>' \
  -H 'Content-Type: application/json' \
  -d @body.json
```