# Change the away message

> Turns it on or off, or changes its words, your hours or how often one person can get it.

`PATCH /v1/automations/away`

Turns it on or off, or changes its words, your hours or how often one person can get it. It goes to a one-to-one text that arrives outside your hours when no keyword rule replied, at most once per person per `cooldown_hours`.

Needs a key with the `messages:send` scope. [Keys and scopes](https://usebluebot.com/docs/concepts/api-keys)

## Request body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `enabled` | boolean | No |   |
| `text` | string | No | The reply, with `{{variables}}`. Up to 2,000 characters |
| `cooldown_hours` | integer | No | 1 to 168 |
| `business_hours` | object | No | Your hours each day in your time zone; null for a day you’re closed. |
| `business_hours.mon` | object or null | Yes |   |
| `business_hours.mon.start` | string | Yes | A time of day as HH:MM in your account’s time zone. |
| `business_hours.mon.end` | string | Yes | A time of day as HH:MM in your account’s time zone. |
| `business_hours.tue` | object or null | Yes |   |
| `business_hours.tue.start` | string | Yes | A time of day as HH:MM in your account’s time zone. |
| `business_hours.tue.end` | string | Yes | A time of day as HH:MM in your account’s time zone. |
| `business_hours.wed` | object or null | Yes |   |
| `business_hours.wed.start` | string | Yes | A time of day as HH:MM in your account’s time zone. |
| `business_hours.wed.end` | string | Yes | A time of day as HH:MM in your account’s time zone. |
| `business_hours.thu` | object or null | Yes |   |
| `business_hours.thu.start` | string | Yes | A time of day as HH:MM in your account’s time zone. |
| `business_hours.thu.end` | string | Yes | A time of day as HH:MM in your account’s time zone. |
| `business_hours.fri` | object or null | Yes |   |
| `business_hours.fri.start` | string | Yes | A time of day as HH:MM in your account’s time zone. |
| `business_hours.fri.end` | string | Yes | A time of day as HH:MM in your account’s time zone. |
| `business_hours.sat` | object or null | Yes |   |
| `business_hours.sat.start` | string | Yes | A time of day as HH:MM in your account’s time zone. |
| `business_hours.sat.end` | string | Yes | A time of day as HH:MM in your account’s time zone. |
| `business_hours.sun` | object or null | Yes |   |
| `business_hours.sun.start` | string | Yes | A time of day as HH:MM in your account’s time zone. |
| `business_hours.sun.end` | string | Yes | A time of day as HH:MM in your account’s time zone. |

## Example

```bash
curl -X PATCH "https://usebluebot.com/api/v1/automations/away" \
  -H "Authorization: Bearer $BLUEBOT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "enabled": true,
    "cooldown_hours": 12
  }'
```

```ts
import BlueBot from '@usebluebot/sdk';

const client = new BlueBot({ apiKey: process.env.BLUEBOT_API_KEY });

const away = await client.automations.away.update({
  enabled: true,
  cooldownHours: 12,
});
console.log(away);
```

```python
import os
from bluebot import BlueBot

client = BlueBot(api_key=os.environ["BLUEBOT_API_KEY"])

away = client.automations.away.update(enabled=True, cooldown_hours=12)
print(away)
```

## Response

`200`: The away message.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `object` | "away_message" | Yes |   |
| `enabled` | boolean | Yes |   |
| `text` | string or null | Yes | The reply, with `{{variables}}`. |
| `cooldown_hours` | integer | Yes | Each person gets it at most once in this many hours. |
| `business_hours` | object | Yes | Your hours each day in your time zone; null for a day you’re closed. |
| `business_hours.mon` | object or null | Yes |   |
| `business_hours.mon.start` | string | Yes | A time of day as HH:MM in your account’s time zone. |
| `business_hours.mon.end` | string | Yes | A time of day as HH:MM in your account’s time zone. |
| `business_hours.tue` | object or null | Yes |   |
| `business_hours.tue.start` | string | Yes | A time of day as HH:MM in your account’s time zone. |
| `business_hours.tue.end` | string | Yes | A time of day as HH:MM in your account’s time zone. |
| `business_hours.wed` | object or null | Yes |   |
| `business_hours.wed.start` | string | Yes | A time of day as HH:MM in your account’s time zone. |
| `business_hours.wed.end` | string | Yes | A time of day as HH:MM in your account’s time zone. |
| `business_hours.thu` | object or null | Yes |   |
| `business_hours.thu.start` | string | Yes | A time of day as HH:MM in your account’s time zone. |
| `business_hours.thu.end` | string | Yes | A time of day as HH:MM in your account’s time zone. |
| `business_hours.fri` | object or null | Yes |   |
| `business_hours.fri.start` | string | Yes | A time of day as HH:MM in your account’s time zone. |
| `business_hours.fri.end` | string | Yes | A time of day as HH:MM in your account’s time zone. |
| `business_hours.sat` | object or null | Yes |   |
| `business_hours.sat.start` | string | Yes | A time of day as HH:MM in your account’s time zone. |
| `business_hours.sat.end` | string | Yes | A time of day as HH:MM in your account’s time zone. |
| `business_hours.sun` | object or null | Yes |   |
| `business_hours.sun.start` | string | Yes | A time of day as HH:MM in your account’s time zone. |
| `business_hours.sun.end` | string | Yes | A time of day as HH:MM in your account’s time zone. |
| `time_zone` | string | Yes |   |
| `open_now` | boolean | Yes | Whether it’s inside your business hours right now. |

The answer, `200`:

```json
{
  "object": "away_message",
  "enabled": true,
  "text": "Thanks for your text! We’re closed right now and will reply when we open at 9 AM.",
  "cooldown_hours": 12,
  "business_hours": {
    "mon": {
      "start": "09:00",
      "end": "17:00"
    },
    "tue": {
      "start": "09:00",
      "end": "17:00"
    },
    "wed": {
      "start": "09:00",
      "end": "17:00"
    },
    "thu": {
      "start": "09:00",
      "end": "17:00"
    },
    "fri": {
      "start": "09:00",
      "end": "17:00"
    },
    "sat": null,
    "sun": null
  },
  "time_zone": "America/Chicago",
  "open_now": true
}
```

## Errors

Every refusal has the same envelope and a page of its own. These are the ones this operation can give.

| Code                                                    | Status | What it means                                                                                                                                    |
| ------------------------------------------------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| [`unauthorized`](https://usebluebot.com/docs/errors/unauthorized)             | 401    | The request carried no key, or a key BlueBot doesn’t know: mistyped, revoked, or a test key sent to the live API.                                |
| [`insufficient_scope`](https://usebluebot.com/docs/errors/insufficient_scope) | 403    | The key doesn’t carry the scope the endpoint needs. Each endpoint’s reference names its scope.                                                   |
| [`rate_limited`](https://usebluebot.com/docs/errors/rate_limited)             | 429    | Too many requests. A key may make 120 requests a minute. The `RateLimit` header says how many are left, and `Retry-After` how long to wait.      |
| [`internal`](https://usebluebot.com/docs/errors/internal)                     | 500    | Something went wrong on BlueBot’s side. It was reported. Send the request again; with an Idempotency-Key that is always safe.                    |
| [`invalid_request`](https://usebluebot.com/docs/errors/invalid_request)       | 400    | Something in the request doesn’t fit: a missing or malformed field, a bad id, or a combination the endpoint refuses. `details` names each field. |

## Try it
