---
title: "Opt in a contact by phone"
method: POST
path: "/contacts/by-phone/{phone}/opt-in"
tags: ["Contacts"]
---

# Opt in a contact by phone

`POST /contacts/by-phone/{phone}/opt-in`

## Request

- Base URL: `https://api.textla.com/v1`
- URL: `https://api.textla.com/v1/contacts/by-phone/{phone}/opt-in`
- Auth: HTTP bearer

Records a hard opt-in for an E.164 phone under the authenticated account. The account is taken from the bearer token, never from the request; the Contacts Service creates the contact if it does not exist. Returns the updated contact and ETag with HTTP 200.

## Path parameters

- `phone` string, required: E.164 phone number identifying the contact

## Request body

- OptInContactBody
  - `$schema` string, uri: A URL to the JSON Schema for this object.
  - `actor` string, required: User or system that triggered the opt-in
  - `source` string, required: System or interface that triggered the opt-in
  - `voluntary` boolean: Whether this is consumer-initiated re-consent

## Response `200`

OK

- Contact
  - `$schema` string, uri: A URL to the JSON Schema for this object.
  - `account_id` string, required
  - `birth_date` string, nullable, required
  - `carrier` string, nullable, required
  - `city` string, nullable, required
  - `company` string, nullable, required
  - `contact_type` string, required
  - `country` string, nullable, required
  - `created_at` integer, required: When the contact record was created, as milliseconds since the Unix epoch
  - `custom_fields` CustomFieldValue[], nullable, required
    - `field_id` string
    - `name` string
    - `value` unknown, required
  - `email` string, nullable, required
  - `first_name` string, nullable, required
  - `groups` string[], nullable, required
  - `id` integer, required
  - `keywords` string[], nullable, required
  - `last_active_at` integer, nullable, required: When the contact was last active (used for aging), as milliseconds since the Unix epoch. Null when never recorded
  - `last_communicated_at` integer, nullable, required: When a message was last sent to this contact, as milliseconds since the Unix epoch. Null until the first send
  - `last_name` string, nullable, required
  - `location` Location, required
    - `lat` number, double, required
    - `lon` number, double, required
  - `marked_invalid_at` integer, nullable, required: When the contact's phone number was marked invalid (for example, after a hard delivery failure), as milliseconds since the Unix epoch. Null while the number is considered valid
  - `opted_in_at` integer, nullable, required: When the contact opted in to messaging, as milliseconds since the Unix epoch. Null if the contact has never opted in
  - `opted_out_at` integer, nullable, required: When the contact opted out of messaging, as milliseconds since the Unix epoch. Null while the contact is opted in. A non-null value means the contact must not be messaged
  - `phone` string, required
  - `postal_code` string, nullable, required
  - `signed_up_at` integer, nullable, required: When the contact signed up, as milliseconds since the Unix epoch. Null when not provided
  - `soft_opted_out_at` integer, nullable, required: When the contact was soft opted out, as milliseconds since the Unix epoch. Null while the contact is not soft opted out
  - `state` string, nullable, required
  - `street` string, nullable, required
  - `tags` string[], nullable, required
  - `updated_at` integer, required: When the contact record was last changed, as milliseconds since the Unix epoch

## Other responses

- `400`: Bad Request
- `401`: Unauthorized
- `403`: Forbidden
- `404`: Not Found
- `412`: Precondition Failed
- `422`: Unprocessable Entity
- `500`: Internal Server Error
- `502`: Bad Gateway
- `503`: Service Unavailable
- `504`: Gateway Timeout

---

[API](https://skmtc.dev/textla/apis/textla-api.md) - [All operations](https://skmtc.dev/textla/apis/textla-api/llms.txt) - [OpenAPI document](https://skmtc.dev/textla/apis/textla-api/revisions/473f03350bc1?raw)
