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

# Record SMS consent

> Record consent or withdrawal for the current Nixflex SMS campaign policy revision. Review the audience and policy before confirming.

**FIXED · campaign** **MUST** Resume covers only unattempted work in the existing running launch, and neither resume nor reuse replays completed work.\
reuse\_campaign\_id replaces settings and recipients atomically only on an owned, never-launched voice draft or scheduled campaign. A launch claim prevents replacement. SMS creation always generates a fresh ID, even if the request forwards this field. Omit it for SMS.

**NOT OFFERED → do this instead · campaign** A launched or finished campaign cannot run again. For another run create a campaign with a fresh ID, selected recipients and reviewed settings. The dashboard’s Use again button follows the same rule for voice: it edits a campaign that never launched, otherwise it opens a new campaign filled with the original settings and recipients for review before launch. SMS campaigns have no Use again button.

**YOU CAN CHANGE · campaign** Use schedule\_type=schedule, scheduled\_date (YYYY-MM-DD), timezone, window\_days and optional paired window\_start\_minutes/window\_end\_minutes. UTC date checks, local windows and capacity apply.

**SCOPE · campaign** `DELETE /v1/calls/batch/{id}` deletes a voice campaign. Voice and SMS have separate cancel routes. Cancel stops future work. Running attempts may finish.

For one owned sender, send business\_number (encode + as %2B) on `GET /v1/campaigns` or `GET /v1/sms/campaigns`. Omit for account scope. Keep the same number and status through SMS cursors. Restart paging if either changes. Voice include\_totals=true covers returned campaigns only (default 50, max 200).

Pickup rate = answered attempts / all attempts, including failed starts. Answered means over five seconds with no detected voicemail. Sum counts before dividing. Zero attempts means no rate. SMS delivery rate = delivered / (delivered + failed).

[Read the compact AI rules](https://docs.nixflex.com/ai-rules.md#campaigns)

Record a consent or consent-withdrawal decision for the current SMS campaign policy revision. The owner confirms the selected event explicitly.

Method: **POST** · Success: **200** · Scope: **Owning account**

**The important part**

* Save consent only when it was actually obtained.
* A consent record does not override suppression or allowed contact hours.

[Business guide](https://docs.nixflex.com/guides/business/sms-campaigns.md) · [Developer guide](https://docs.nixflex.com/sms/sms-campaigns.md) · [Glossary](https://docs.nixflex.com/guides/glossary.md)

Review the audience and policy, then record the actual consent decision for the current campaign revision before launch. A revision identifies the campaign policy you confirmed. Reusing a campaign creates a new revision and invalidates earlier confirmations. A campaign confirmation does not override a recipient’s STOP.

### The consent rule in plain words

* **When it applies.** Nixflex can require a consent confirmation before campaign texts are sent. This requirement is managed by Nixflex and may be off. While it is on, each recipient waits with `consent_required` until consent is recorded for the campaign.
* **What the owner confirms.** Recording `consent` confirms that your business has permission to contact the recipients in this campaign on this channel. It is your statement; Nixflex does not check it.
* **What the policy revision is.** The revision is the version of this campaign’s recipients and contact settings that you are confirming. A new campaign starts a new revision, so a confirmation never carries over to another campaign. Reusing an SMS campaign creates a new campaign, which needs its own confirmation. Later edits to is\_active, the reply context or the reply window keep the same revision.
* **Withdrawal.** Recording `consent_withdrawn` holds the remaining recipients with `consent_withdrawn`, even when Nixflex does not require confirmations.
* **Your own rules.** Nixflex does not decide which texts are legal in each country. Check the rules that apply to your business before you launch. For example, marketing texts usually need prior consent, while service or reminder texts to existing customers often have different rules. This is not legal advice.

If you already have the necessary permission, `consent_confirmed: true` can record it when creating the campaign. Use the consent endpoint for a subsequent confirmation or withdrawal.

## Authentication

Send `Authorization: Bearer KEY_ID:KEY_SECRET` using the owning account’s server-side credential. Send `Content-Type: application/json`.

## Request fields

| Field | Type | Required | Default | Limits and meaning |
| - | - | - | - | - |
| `id` (path) | string | Yes | None | Account-owned campaign identifier. Maximum 100 characters. Minimum 1 characters. Pattern: `^[A-Za-z0-9_-]+$`. |

Send a JSON object.

| Field | Type | Required | Default | Limits and meaning |
| - | - | - | - | - |
| `event` | string | Yes | None | Decision to record. Allowed: `"consent"`, `"consent_withdrawn"`. |
| `confirmed` | boolean | Yes | None | Explicitly confirm the selected event, including withdrawal. Value: `true`. |

confirmed must be true for either event. Omitted fields and false are refused. This endpoint does not launch a campaign or clear suppression. Recording consent can unblock otherwise eligible scheduled or running work. Missing campaigns and unconfirmed database results currently return 503 outcome\_unknown.

## Response fields

`200 OK` returns the shape below. Nullable fields can be unknown or unset; do not turn null into zero or false.

| Field | Type | Meaning |
| - | - | - |
| `campaign_id` | string | Campaign ID. |
| `recorded` | boolean | The decision was recorded. Value: `true`. |

## Example request

These examples require Node/CLI 0.11.0 or later, Python 0.4.0 or later and MCP 0.5.0 or later. Keep `NIXFLEX_API_KEY` private. cURL uses Bash; CLI uses PowerShell and reads the key through `NIXFLEX_API_KEY`. Replace fixture identifiers and reserved example numbers with approved account-owned values. Configure the existing MCP installation for the same account at `https://api.nixflex.com` before using the shown tool arguments. Python shows the synchronous client; `AsyncNixflex` uses the same method with `async with` and `await`. This example changes state. Review the target and payload before running it.

```bash cURL theme={"dark"}
curl --request POST \
  --url "https://api.nixflex.com/v1/sms/campaigns/campaign_fixture/consent" \
  --header "Authorization: Bearer $NIXFLEX_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{"event":"consent","confirmed":true}'
```

```javascript Node theme={"dark"}
import Nixflex from 'nixflex';

const c = new Nixflex({
  apiKey: process.env.NIXFLEX_API_KEY,
  baseUrl: 'https://api.nixflex.com',
  maxRetries: 0,
});
const result = await c.sms.campaigns.consent("campaign_fixture", {"event": "consent", "confirmed": true});
```

```python Python theme={"dark"}
import os
from nixflex import Nixflex

with Nixflex(
    api_key=os.environ["NIXFLEX_API_KEY"],
    base_url="https://api.nixflex.com",
    max_retries=0,
) as c:
    result = c.sms.campaigns.consent('campaign_fixture', event='consent', confirmed=True)
```

```powershell CLI (PowerShell) theme={"dark"}
$body = @'
{
  "event": "consent",
  "confirmed": true
}
'@
[IO.File]::WriteAllText('request-181.json', $body, (New-Object Text.UTF8Encoding $false))
nixflex sms campaigns consent campaign_fixture --body '@request-181.json' --confirm --json --base-url "https://api.nixflex.com"
```

MCP does not offer this operation because it can enable outreach; use the API, Node, CLI or Python.

## Example response

Illustrative `200` response. Identifiers and values are examples; some optional or compatibility fields are omitted.

```json Response theme={"dark"}
{
  "campaign_id": "campaign_example",
  "recorded": true
}
```

## Errors

Failures return an `error` object with `code`, `message`, `doc_url` and optional details. Each code links to the shared error catalog. Read the message and details before deciding whether to resend.

| Status | Code | Meaning | What to do |
| - | - | - | - |
| 400 | [`invalid_request`](https://docs.nixflex.com/api-reference/errors#invalid_request) | The identifier or request fields are invalid. | Correct the documented fields before resending. |
| 503 | [`outcome_unknown`](https://docs.nixflex.com/api-reference/errors#outcome_unknown) | The write result could not be confirmed. | Read current state; do not resend automatically. |
| 400 | [`invalid_json`](https://docs.nixflex.com/api-reference/errors#invalid_json) | Invalid JSON body. | Correct JSON syntax. |
| 413 | [`payload_too_large`](https://docs.nixflex.com/api-reference/errors#payload_too_large) | The request exceeds the JSON body limit. | Send a smaller request. |
| 401 | [`unauthorized`](https://docs.nixflex.com/api-reference/errors#unauthorized) | The credential is missing or invalid. | Check the full account credential. |
| 429 | [`rate_limit_exceeded`](https://docs.nixflex.com/api-reference/errors#rate_limit_exceeded) | The account request limit was reached. | Wait for Retry-After. Reconcile uncertain writes before resending. |

## Retry and idempotency

No idempotency key is documented. A timeout or 5xx can follow a committed change. Read the current state before deciding whether to submit again; never automatically repeat an uncertain write. Each accepted request appends a decision event; it is not a deduplicated update.

## Related endpoints

* [List SMS campaigns](https://docs.nixflex.com/api-reference/sms/campaigns-list.md)
* [Create an SMS campaign](https://docs.nixflex.com/api-reference/sms/campaigns-create.md)
* [Errors and recovery](https://docs.nixflex.com/api-reference/errors.md#error-envelope)


## OpenAPI

````yaml api-reference/public.openapi.json POST /sms/campaigns/{id}/consent
openapi: 3.1.0
info:
  title: Nixflex public API
  version: 1.0.0
  description: >-
    Nixflex API reference for agents, calls, messaging, knowledge, organisations
    and integrations. Authenticate with the owning account and follow each
    operation’s permissions, response and retry contract.
servers:
  - url: https://api.nixflex.com/v1
security:
  - bearerAuth: []
paths:
  /sms/campaigns/{id}/consent:
    post:
      tags:
        - SMS campaigns
      summary: Record SMS consent
      description: >-
        Record a consent or consent-withdrawal decision for the current SMS
        campaign policy revision. The owner confirms the selected event
        explicitly. confirmed must be true for either event. Omitted fields and
        false are refused. This endpoint does not launch a campaign or clear
        suppression. Recording consent can unblock otherwise eligible scheduled
        or running work. Missing campaigns and unconfirmed database results
        currently return 503 outcome_unknown.
      operationId: post_sms_campaigns_id_consent
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
            description: Account-owned campaign identifier.
            minLength: 1
            maxLength: 100
            pattern: ^[A-Za-z0-9_-]+$
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                event:
                  type: string
                  description: Decision to record.
                  enum:
                    - consent
                    - consent_withdrawn
                confirmed:
                  type: boolean
                  description: Explicitly confirm the selected event, including withdrawal.
                  const: true
              required:
                - event
                - confirmed
              description: ''
              additionalProperties: false
            example:
              event: consent
              confirmed: true
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  campaign_id:
                    type: string
                    description: Campaign ID.
                  recorded:
                    type: boolean
                    description: The decision was recorded.
                    const: true
                required:
                  - campaign_id
                  - recorded
                description: ''
                additionalProperties: false
              example:
                campaign_id: campaign_example
                recorded: true
        '400':
          description: >-
            invalid_request: The identifier or request fields are invalid.
            invalid_json: Invalid JSON body.
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                        description: Machine-readable error code.
                      message:
                        type: string
                        description: Explanation.
                      doc_url:
                        type: string
                        description: Error reference link.
                      details:
                        type: object
                        properties: {}
                        description: >-
                          Optional context; inspect campaign_id, status, outcome
                          and safe_to_retry for uncertain writes.
                        additionalProperties: true
                    required:
                      - code
                      - message
                      - doc_url
                      - type
                    description: ''
                    additionalProperties: false
                required:
                  - error
                description: ''
                additionalProperties: false
        '401':
          description: 'unauthorized: The credential is missing or invalid.'
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                        description: Machine-readable error code.
                      message:
                        type: string
                        description: Explanation.
                      doc_url:
                        type: string
                        description: Error reference link.
                      details:
                        type: object
                        properties: {}
                        description: >-
                          Optional context; inspect campaign_id, status, outcome
                          and safe_to_retry for uncertain writes.
                        additionalProperties: true
                    required:
                      - code
                      - message
                      - doc_url
                      - type
                    description: ''
                    additionalProperties: false
                required:
                  - error
                description: ''
                additionalProperties: false
        '413':
          description: 'payload_too_large: The request exceeds the JSON body limit.'
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                        description: Machine-readable error code.
                      message:
                        type: string
                        description: Explanation.
                      doc_url:
                        type: string
                        description: Error reference link.
                      details:
                        type: object
                        properties: {}
                        description: >-
                          Optional context; inspect campaign_id, status, outcome
                          and safe_to_retry for uncertain writes.
                        additionalProperties: true
                    required:
                      - code
                      - message
                      - doc_url
                      - type
                    description: ''
                    additionalProperties: false
                required:
                  - error
                description: ''
                additionalProperties: false
        '429':
          description: 'rate_limit_exceeded: The account request limit was reached.'
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                        description: Machine-readable error code.
                      message:
                        type: string
                        description: Explanation.
                      doc_url:
                        type: string
                        description: Error reference link.
                      details:
                        type: object
                        properties: {}
                        description: >-
                          Optional context; inspect campaign_id, status, outcome
                          and safe_to_retry for uncertain writes.
                        additionalProperties: true
                    required:
                      - code
                      - message
                      - doc_url
                      - type
                    description: ''
                    additionalProperties: false
                required:
                  - error
                description: ''
                additionalProperties: false
        '503':
          description: 'outcome_unknown: The write result could not be confirmed.'
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                        description: Machine-readable error code.
                      message:
                        type: string
                        description: Explanation.
                      doc_url:
                        type: string
                        description: Error reference link.
                      details:
                        type: object
                        properties: {}
                        description: >-
                          Optional context; inspect campaign_id, status, outcome
                          and safe_to_retry for uncertain writes.
                        additionalProperties: true
                    required:
                      - code
                      - message
                      - doc_url
                      - type
                    description: ''
                    additionalProperties: false
                required:
                  - error
                description: ''
                additionalProperties: false
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        KEY_ID:KEY_SECRET from the owning account. Keep it server-side. A
        verified personal dashboard Bearer session may be used where the
        operation documents role-based access.

````

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