> This page is part of EVVA for Developers (https://developers.evvahub.com), the documentation of the EVVA Partner API. The API is in developer preview and the SDK packages are not yet published: do not suggest installing them. Index: https://developers.evvahub.com/llms.txt

# Set a message automation

PUT https://api.evvahub.com/partner/v1/accounts/{creatorId}/message-automations/{trigger}
Content-Type: application/json

Creates or replaces the creator's automation rule for one trigger.

**Request**

Every write replaces the whole rule. A write that does not set or change the price is idempotent by nature and needs
no `Idempotency-Key`.

**Authorship**

The body must declare `authorship`; see [message authorship](/message-authorship).

* `AI_AUTOMATED` needs `write:messages:automated`.
* `HUMAN_AUTHORED` or `AI_DRAFTED_HUMAN_SENT` needs `write:messages:operator` and an `operatorRef`.

**Switching it on**

A write that switches the rule on needs the creator's account to permit bulk messaging (`BULK_MESSAGING`).
Switching it off never does.

**Price**

The rule accepts `unlockPrice` (alias `price`) as `{minor, currency}`. `minor` is a string of minor units, in USD,
from `100` to `1000000`, and a priced rule needs at least one attachment. When a write sets or changes the price:

1. Your application's effective access must cover `write:paid_messages`
   ([scopes and grants](/authentication/scopes)). Otherwise the write is refused and nothing is written.
2. The write must carry an `Idempotency-Key`.
3. It then goes through [action approval](/approvals), with the price as the amount. Within the agency's own
   automatic limits it is saved. Otherwise you receive `202 APPROVAL_REQUIRED`: once a person approves, re-send the
   same request with `Partner-Approval-Id`.

The approval covers the trigger, the message, its attachments, the price and `blurPreview`. Sending back the stored
price unchanged is not setting a price: it needs neither the scope nor approval.

**Delivery**

The rule's sends pass the same coordination as the creator's own automation: a
[conversation lease](/conversation-leases), a handoff or a person's recent reply suppresses them. Fans receive them
as the creator's own automated message.

**Errors**

* `400 AUTHORSHIP_REQUIRED` — the body declares no `authorship`.
* `400 IDEMPOTENCY_KEY_REQUIRED` — the write sets or changes the price without an `Idempotency-Key`. Nothing is
  written.
* `403 AUTHORSHIP_NOT_PERMITTED` — the creator's consent does not cover the declared authorship.
* `403 CREATOR_SUSPENDED` — the write switches the rule on while the creator's account does not permit bulk
  messaging.
* `403 PRICE_NOT_PERMITTED` — the price was refused and nothing was written. `details.reason` is `CONSENT` when your
  application's effective access lacks `write:paid_messages`, and `ACTION_APPROVAL_REQUIRED` when the price is not
  valid (see **Price**), so it could not go through action approval.
* `403 ACTION_DENIED_BY_POLICY` — the agency's policy does not allow your application to set this price.
* `403 ENVIRONMENT_MISMATCH` — a [sandbox](/sandbox) application reaches only its sandbox creators.

**Required scopes:** `write:automations`.

**Approval:** setting or changing `unlockPrice` runs through [action approval](/approvals).

Reference: https://developers.evvahub.com/api-reference/automations/upsert-message-automation

## Authentication

- `Authorization` header (bearer token, required) — OAuth 2.0 client credentials. Request an access token at `POST /partner/v1/oauth/token` (`grant_type=client_credentials`) with the application's client secret or a `private_key_jwt` assertion, then send it as `Authorization: Bearer evpa_live_…` (or `evpa_test_…` for a sandbox application). Tokens are opaque and short lived (see `expires_in`); there is no refresh token. Each operation lists the scopes it requires.

## Request

### Path parameters

- `creatorId` (string, required) — The creator profile id — the ONLY source of the creator a request acts for.
- `trigger` (enum, required) — An unknown trigger answers 404 NOT_FOUND.
  - Allowed values: `TIP_RECEIVED`, `SUBSCRIPTION_ENDED`, `FAN_WENT_QUIET`, `UNLOCK_PURCHASED`

### Headers

- `X-Creator-Id` (string, optional) — Optional echo of the path `creatorId`; any other value is refused with 403 CREATOR_CONTEXT_MISMATCH.
- `Idempotency-Key` (string, optional) — Your key for this request. It is required when the request sets or changes one of the operation's `conditionalFields`: without it the request is `400 IDEMPOTENCY_KEY_REQUIRED` and nothing is done. The same key re-sent with its `Partner-Approval-Id` is that request again; the same key for a different action is `409 IDEMPOTENCY_KEY_REUSED`. See [action approval](/approvals).
- `Partner-Approval-Id` (string, optional) — The `approvalId` a previous `202 APPROVAL_REQUIRED` returned, for an operation your application may run only with approval. Re-send it with the same payload once a person has approved. A blank value is no approval. The approval is spent once, for exactly that agency, application, creator, operation and payload digest, the same amount and currency, and at most the units it was given for. It is claimed for the request's `Idempotency-Key` (required) and becomes final when the operation succeeds: - A refusal before the effect, a `4xx` or `429`, hands it back for your next attempt. - A `5xx`, `503` included, keeps it claimed for this key, because the effect may have happened. It is handed back only when EVVA knows nothing was done. - The same key re-sent replays the request and never has a second effect. You get the stored result where the operation keeps one, otherwise `409 APPROVAL_CONSUMED` with `details.replay: true`: read the resource to see the result. - Another key is `409 APPROVAL_CONSUMED`. When the approval cannot be used, the request is refused with `403` (`APPROVAL_INVALID`, `APPROVAL_MISMATCH` or `APPROVAL_DECLINED`) or `409` (`APPROVAL_PENDING`, `APPROVAL_EXPIRED` or `APPROVAL_CONSUMED`). See [action approval](/approvals).

### Body (application/json)

This endpoint expects an UpsertMessageAutomationRequest.

- `body` (string, required)
- `enabled` (boolean, optional) — Absent means false.
- `delaySeconds` (integer, optional, default: 0)
- `quietAfterDays` (integer, optional, nullable) — FAN_WENT_QUIET only (default 14).
- `attachments` (list of string, optional)
- `mediaAssetIds` (list of string, optional) — Alias of `attachments`.
- `unlockPrice` (UpsertMessageAutomationRequestUnlockPrice, optional, nullable) — The rule's price; `price` is accepted as an alias. Null or absent means free. A price that is set or changed needs at least one attachment and `write:paid_messages`, and goes through [action approval](/approvals). Sending back the stored price unchanged needs neither the scope nor approval.
- `blurPreview` (boolean, optional, default: true)
- `authorship` (enum, optional) — REQUIRED for an application: `AI_AUTOMATED` needs `write:messages:automated`; `HUMAN_AUTHORED` / `AI_DRAFTED_HUMAN_SENT` need `write:messages:operator` and `operatorRef`. Internal (agency audit) only — the fan sees the creator's own message.
  - Allowed values: `AI_AUTOMATED`, `HUMAN_AUTHORED`, `AI_DRAFTED_HUMAN_SENT`
- `operatorRef` (string, optional) — The external CRM's opaque operator id — required with HUMAN_AUTHORED / AI_DRAFTED_HUMAN_SENT, refused otherwise. Agency audit only.

## Response

### 200

Saved.

- `rule` (MessageAutomationRule, required)

### 202

The action waits for an authorised person of the agency, and nothing was done. It waits because the agency has no policy for it, its policy requires approval, or the action is over the agency's own automatic limit (`LIMIT_EXCEEDED`). Once an `approval.decided` event approves it, re-send the same request with `Partner-Approval-Id: <approvalId>`. See [action approval](/approvals).

- `code` (enum, required)
  - Allowed values: `APPROVAL_REQUIRED`
- `error` (string, required)
- `approvalId` (string, required)
- `status` (enum, required) — The status of an approval request. Reads show the effective status. - `PENDING` becomes `APPROVED`, `DECLINED`, `EXPIRED` or `REVOKED`. - `APPROVED` becomes `CONSUMED`, `EXPIRED` or `REVOKED`. - `REVOKED` means the request was voided: its access was withdrawn (grant or consent link), the application or agency stopped, the creator was held or restricted, or the policy that governed it was replaced. `revokedReason` says which.
  - Allowed values: `PENDING`, `APPROVED`, `DECLINED`, `EXPIRED`, `CONSUMED`, `REVOKED`
- `reason` (enum, required) — Why the action was not automatic: no policy (the default), a policy that asks for approval, or over a limit.
  - Allowed values: `NO_POLICY`, `POLICY_REQUIRES_APPROVAL`, `LIMIT_EXCEEDED`
- `expiresAt` (datetime, required)
- `requestId` (string, optional, nullable)

## Errors

### 400 Bad Request Error

Invalid or missing parameters: `INVALID_REQUEST` (`details` names the fields), or a more specific code of the operation.

- `code` (string, required) — A stable machine-readable code (see `KnownErrorCode`; new codes may appear within v1).
- `error` (string, required)
- `requestId` (string, required, nullable) — The same value as the `X-Request-Id` response header — quote it when reporting a problem.
- `details` (any, optional) — Extra detail for the code, specific to the operation, such as field errors, limits or the creator's account-status details.

### 401 Unauthorized Error

Token missing, malformed, expired or revoked: `INVALID_TOKEN` (or `UNAUTHORIZED` when no bearer token was sent). Request a new token and retry.

- `code` (string, required) — A stable machine-readable code (see `KnownErrorCode`; new codes may appear within v1).
- `error` (string, required)
- `requestId` (string, required, nullable) — The same value as the `X-Request-Id` response header — quote it when reporting a problem.
- `details` (any, optional) — Extra detail for the code, specific to the operation, such as field errors, limits or the creator's account-status details.

### 403 Forbidden Error

Not your creator (`GRANT_REVOKED`, `INSUFFICIENT_SCOPE`, …), the creator's account status blocks bulk messaging (`CREATOR_SUSPENDED`), or a price needs a grant covering `write:paid_messages` (`PRICE_NOT_PERMITTED`).

- `code` (string, required) — A stable machine-readable code (see `KnownErrorCode`; new codes may appear within v1).
- `error` (string, required)
- `requestId` (string, required, nullable) — The same value as the `X-Request-Id` response header — quote it when reporting a problem.
- `details` (any, optional) — Extra detail for the code, specific to the operation, such as field errors, limits or the creator's account-status details.

### 404 Not Found Error

No such resource, or it belongs to another creator: `NOT_FOUND` or a more specific code.

- `code` (string, required) — A stable machine-readable code (see `KnownErrorCode`; new codes may appear within v1).
- `error` (string, required)
- `requestId` (string, required, nullable) — The same value as the `X-Request-Id` response header — quote it when reporting a problem.
- `details` (any, optional) — Extra detail for the code, specific to the operation, such as field errors, limits or the creator's account-status details.

### 409 Conflict Error

`MEDIA_NOT_READY` (an attached file is not ready to send yet; nothing was written), an approval for a priced rule that is still pending, expired or already used (`APPROVAL_PENDING`, `APPROVAL_EXPIRED`, `APPROVAL_CONSUMED`), or an Idempotency-Key used for a different action (`IDEMPOTENCY_KEY_REUSED`).

- `code` (string, required) — A stable machine-readable code (see `KnownErrorCode`; new codes may appear within v1).
- `error` (string, required)
- `requestId` (string, required, nullable) — The same value as the `X-Request-Id` response header — quote it when reporting a problem.
- `details` (any, optional) — Extra detail for the code, specific to the operation, such as field errors, limits or the creator's account-status details.

### 429 Too Many Requests Error

Rate limited: `RATE_LIMIT_EXCEEDED`. Wait `Retry-After` seconds before retrying.

- `code` (enum, required) — A stable machine-readable code (see `KnownErrorCode`; new codes may appear within v1).
  - Allowed values: `RATE_LIMIT_EXCEEDED`, `TOO_MANY_MESSAGES`
- `error` (string, required)
- `requestId` (string, required, nullable) — The same value as the `X-Request-Id` response header — quote it when reporting a problem.
- `details` (RateLimitErrorDetails, optional) — Extra detail for the code, specific to the operation, such as field errors, limits or the creator's account-status details.

### 500 Internal Server Error

Unexpected server error: `INTERNAL_ERROR`. Nothing internal is disclosed; quote the `X-Request-Id` when you report it.

- `code` (string, required) — A stable machine-readable code (see `KnownErrorCode`; new codes may appear within v1).
- `error` (string, required)
- `requestId` (string, required, nullable) — The same value as the `X-Request-Id` response header — quote it when reporting a problem.
- `details` (any, optional) — Extra detail for the code, specific to the operation, such as field errors, limits or the creator's account-status details.

### 503 Service Unavailable Error

Temporarily unavailable: `SERVICE_UNAVAILABLE`, `TEMPORARILY_UNAVAILABLE`, `MEDIA_STORAGE_UNAVAILABLE` or `CREATOR_STANDING_UNAVAILABLE`. Retry after `Retry-After` seconds.

- `code` (string, required) — A stable machine-readable code (see `KnownErrorCode`; new codes may appear within v1).
- `error` (string, required)
- `requestId` (string, required, nullable) — The same value as the `X-Request-Id` response header — quote it when reporting a problem.
- `details` (any, optional) — Extra detail for the code, specific to the operation, such as field errors, limits or the creator's account-status details.

## Types

### UpsertMessageAutomationRequestUnlockPrice

The rule's price; `price` is accepted as an alias. Null or absent means free. A price that is set or changed needs at least one attachment and `write:paid_messages`, and goes through [action approval](/approvals). Sending back the stored price unchanged needs neither the scope nor approval.

- `minor` (string, required)
- `currency` (enum, required)
  - Allowed values: `USD`

### MessageAutomationRule

- `id` (string, required)
- `trigger` (enum, required)
  - Allowed values: `TIP_RECEIVED`, `SUBSCRIPTION_ENDED`, `FAN_WENT_QUIET`, `UNLOCK_PURCHASED`
- `enabled` (boolean, required) — A rule an integration application configured asks that application's CURRENT access before every send. When that access is gone it is switched off (`false`) and stays off until a person writes it again; re-enabling the application does not switch it back on, and the application's own write keeps it off (`false` in the answer) whatever it sends.
- `delaySeconds` (integer, required)
- `quietAfterDays` (integer, required, nullable)
- `body` (string, required)
- `mediaAssetIds` (list of string, required)
- `unlockPrice` (MessageAutomationRuleUnlockPrice, required, nullable)
- `stats` (MessageAutomationRuleStats, required)
- `createdAt` (datetime, required)
- `updatedAt` (datetime, required)
- `pausedAt` (datetime, optional, nullable) — `null` when it is not paused. Paused is not the same as off: a paused item waits for the creator's decision, and an application cannot resume, cancel or delete it (409 `PAUSED_AWAITING_CREATOR`).
- `pauseReason` (string, optional, nullable) — Why it was paused — the access refusal (for example `APP_DISABLED`, `APP_REVOKED`, `NOT_ASSIGNED`, `GRANT_REVOKED`, `AGENCY_SUSPENDED`, `CREATOR_INTEGRATIONS_HELD`, `CONSENT_SCOPE_MISSING`, `CREATOR_RESTRICTED`); `null` when it is not paused.

### RateLimitErrorDetails

Extra detail for the code, specific to the operation, such as field errors, limits or the creator's account-status details.

- `retryAfterSec` (integer, required)
- `level` (enum, optional) — The DM send limit that refused the message, set only with `TOO_MANY_MESSAGES`. It is never a quota, a count or a key. - `conversation` — one side of one thread. - `sender` — a person's own ceiling; it does not apply to applications. - `creator` — everything sent for the creator, studio included. - `application` — everything your application sends. - `agency` — everything your agency sends. - `platform` — the agency's fair share of the platform: its throughput or its concurrency. See [rate limits](/authentication/rate-limits).
  - Allowed values: `conversation`, `sender`, `creator`, `application`, `agency`, `platform`

### MessageAutomationRuleUnlockPrice

- `minor` (string, required)
- `currency` (string, required)
- `blurPreview` (boolean, required)

### MessageAutomationRuleStats

- `sent` (integer, required)
- `lastSentAt` (datetime, required, nullable)

## Examples

### Automations_upsertMessageAutomation_example

**Request**

```json
{
  "body": "Thank you so much for the tip! It really made my day.",
  "enabled": true,
  "delaySeconds": 60,
  "authorship": "AI_AUTOMATED"
}
```

**Response**

```json
{
  "rule": {
    "id": "cm4s5b7d2001vqz8wl9n3p6qr",
    "trigger": "TIP_RECEIVED",
    "enabled": true,
    "delaySeconds": 60,
    "quietAfterDays": null,
    "body": "Thank you so much for the tip! It really made my day.",
    "mediaAssetIds": [],
    "unlockPrice": null,
    "stats": {
      "sent": 214,
      "lastSentAt": "2026-12-01T21:14:33.208Z"
    },
    "createdAt": "2026-11-03T12:20:45.117Z",
    "updatedAt": "2026-12-02T08:05:19.442Z"
  }
}
```

**SDK Code**

```python Automations_upsertMessageAutomation_example
import requests

url = "https://api.evvahub.com/partner/v1/accounts/cm4r7k2xq0001qz8w3n5v6b2d/message-automations/TIP_RECEIVED"

payload = {
    "body": "Thank you so much for the tip! It really made my day.",
    "enabled": True,
    "delaySeconds": 60,
    "authorship": "AI_AUTOMATED"
}
headers = {
    "Idempotency-Key": "7dc05707-4abc-40ce-99f1-2ca05cf81d60",
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.put(url, json=payload, headers=headers)

print(response.json())
```

```go Automations_upsertMessageAutomation_example
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.evvahub.com/partner/v1/accounts/cm4r7k2xq0001qz8w3n5v6b2d/message-automations/TIP_RECEIVED"

	payload := strings.NewReader("{\n  \"body\": \"Thank you so much for the tip! It really made my day.\",\n  \"enabled\": true,\n  \"delaySeconds\": 60,\n  \"authorship\": \"AI_AUTOMATED\"\n}")

	req, _ := http.NewRequest("PUT", url, payload)

	req.Header.Add("Idempotency-Key", "7dc05707-4abc-40ce-99f1-2ca05cf81d60")
	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```php Automations_upsertMessageAutomation_example
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('PUT', 'https://api.evvahub.com/partner/v1/accounts/cm4r7k2xq0001qz8w3n5v6b2d/message-automations/TIP_RECEIVED', [
  'body' => '{
  "body": "Thank you so much for the tip! It really made my day.",
  "enabled": true,
  "delaySeconds": 60,
  "authorship": "AI_AUTOMATED"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
    'Idempotency-Key' => '7dc05707-4abc-40ce-99f1-2ca05cf81d60',
  ],
]);

echo $response->getBody();
```

### Automations_upsertMessageAutomation_example

**Request**

```json
{
  "body": "Thank you so much for the tip! It really made my day.",
  "enabled": true,
  "delaySeconds": 60,
  "authorship": "AI_AUTOMATED"
}
```

**Response**

```json
{
  "approvalId": "apr_8sKq2VnT4xLm7RcB1pYw9ZdH",
  "code": "APPROVAL_REQUIRED",
  "error": "This action needs the approval of an authorised person",
  "expiresAt": "2026-12-03T14:31:00.000Z",
  "reason": "NO_POLICY",
  "requestId": "2ac01c39-6b45-4a0b-8db1-be67984d2cac",
  "status": "PENDING"
}
```

**SDK Code**

```python Automations_upsertMessageAutomation_example
import requests

url = "https://api.evvahub.com/partner/v1/accounts/cm4r7k2xq0001qz8w3n5v6b2d/message-automations/TIP_RECEIVED"

payload = {
    "body": "Thank you so much for the tip! It really made my day.",
    "enabled": True,
    "delaySeconds": 60,
    "authorship": "AI_AUTOMATED"
}
headers = {
    "Idempotency-Key": "7dc05707-4abc-40ce-99f1-2ca05cf81d60",
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.put(url, json=payload, headers=headers)

print(response.json())
```

```go Automations_upsertMessageAutomation_example
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.evvahub.com/partner/v1/accounts/cm4r7k2xq0001qz8w3n5v6b2d/message-automations/TIP_RECEIVED"

	payload := strings.NewReader("{\n  \"body\": \"Thank you so much for the tip! It really made my day.\",\n  \"enabled\": true,\n  \"delaySeconds\": 60,\n  \"authorship\": \"AI_AUTOMATED\"\n}")

	req, _ := http.NewRequest("PUT", url, payload)

	req.Header.Add("Idempotency-Key", "7dc05707-4abc-40ce-99f1-2ca05cf81d60")
	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```php Automations_upsertMessageAutomation_example
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('PUT', 'https://api.evvahub.com/partner/v1/accounts/cm4r7k2xq0001qz8w3n5v6b2d/message-automations/TIP_RECEIVED', [
  'body' => '{
  "body": "Thank you so much for the tip! It really made my day.",
  "enabled": true,
  "delaySeconds": 60,
  "authorship": "AI_AUTOMATED"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
    'Idempotency-Key' => '7dc05707-4abc-40ce-99f1-2ca05cf81d60',
  ],
]);

echo $response->getBody();
```