> For the complete documentation index, see [llms.txt](https://docs.snapfix.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.snapfix.com/engineering-reference/db/tables/tbl_sms_logs.md).

# tbl\_sms\_logs

{% hint style="info" %}
Generated from the staging database schema, with descriptions drafted by agents ([how to read these docs](https://docs.snapfix.com/how-to-read.md)). [Source on GitHub](https://github.com/snapfix/docs/blob/main/spec/db/tables/tbl_sms_logs.md).
{% endhint %}

## Description

One SMS sent through AWS SNS or Twilio, with recipient, delivery status, carrier and cost in USD; apipy's communication log writes it.

<details>

<summary><strong>Table Definition</strong></summary>

```sql
CREATE TABLE `tbl_sms_logs` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `uuid` char(36) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT (uuid()),
  `sent_at` datetime DEFAULT NULL COMMENT 'When the SMS was sent (UTC)',
  `recipient_phone` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'Destination phone number',
  `message_id` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'AWS/Twilio message identifier',
  `status` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'SUCCESS, FAILURE, DELIVERED, etc.',
  `sms_type` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Transactional / Promotional',
  `carrier` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Mobile carrier name',
  `cost_usd` decimal(10,5) DEFAULT NULL COMMENT 'Price charged for the SMS',
  `message_parts` tinyint unsigned DEFAULT NULL COMMENT 'Number of SMS segments',
  `provider_response` varchar(500) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Carrier delivery response',
  `source` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'AWS SNS or Twilio',
  `fCreatedts` bigint unsigned NOT NULL DEFAULT ((unix_timestamp(now(3)) * 1000)) COMMENT 'Record creation epoch ms',
  PRIMARY KEY (`id`),
  UNIQUE KEY `uk_uuid` (`uuid`),
  UNIQUE KEY `uk_message_id_source` (`message_id`,`source`),
  KEY `idx_sent_at` (`sent_at`),
  KEY `idx_recipient_phone` (`recipient_phone`),
  KEY `idx_status` (`status`),
  KEY `idx_source` (`source`),
  KEY `idx_fCreatedts` (`fCreatedts`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
```

</details>

## Columns

| Name               | Type             | Default                           | Nullable | Extra Definition   | Comment                                                                                                       |
| ------------------ | ---------------- | --------------------------------- | -------- | ------------------ | ------------------------------------------------------------------------------------------------------------- |
| id                 | bigint unsigned  |                                   | false    | auto\_increment    |                                                                                                               |
| uuid               | char(36)         | uuid()                            | false    | DEFAULT\_GENERATED |                                                                                                               |
| sent\_at           | datetime         |                                   | true     |                    | When the SMS was sent (UTC)                                                                                   |
| recipient\_phone   | varchar(20)      |                                   | false    |                    | Destination phone number                                                                                      |
| message\_id        | varchar(255)     |                                   | false    |                    | AWS/Twilio message identifier                                                                                 |
| status             | varchar(20)      |                                   | false    |                    | Delivery status from the provider; DELIVERED, SUCCESS, FAILURE, SENT, FAILED, UNDELIVERED or READ on staging. |
| sms\_type          | varchar(20)      |                                   | true     |                    | Transactional on every staging row.                                                                           |
| carrier            | varchar(100)     |                                   | true     |                    | Mobile carrier name                                                                                           |
| cost\_usd          | decimal(10,5)    |                                   | true     |                    | Price charged for the SMS                                                                                     |
| message\_parts     | tinyint unsigned |                                   | true     |                    | Number of SMS segments                                                                                        |
| provider\_response | varchar(500)     |                                   | true     |                    | Carrier delivery response                                                                                     |
| source             | varchar(20)      |                                   | false    |                    | Twilio or AWS SNS.                                                                                            |
| fCreatedts         | bigint unsigned  | (unix\_timestamp(now(3)) \* 1000) | false    | DEFAULT\_GENERATED | Record creation epoch ms                                                                                      |

## Viewpoints

| Name                                                                                      | Definition                                                                                                     |
| ----------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- |
| [notifications](https://docs.snapfix.com/engineering-reference/db/tables/viewpoint-15.md) | Push device tokens, reminders, notification settings, email and SMS logs, in-app surveys and marketing popups. |

## Constraints

| Name                    | Type        | Definition                                               |
| ----------------------- | ----------- | -------------------------------------------------------- |
| PRIMARY                 | PRIMARY KEY | PRIMARY KEY (id)                                         |
| uk\_message\_id\_source | UNIQUE      | UNIQUE KEY uk\_message\_id\_source (message\_id, source) |
| uk\_uuid                | UNIQUE      | UNIQUE KEY uk\_uuid (uuid)                               |

## Indexes

| Name                    | Definition                                                           |
| ----------------------- | -------------------------------------------------------------------- |
| idx\_fCreatedts         | KEY idx\_fCreatedts (fCreatedts) USING BTREE                         |
| idx\_recipient\_phone   | KEY idx\_recipient\_phone (recipient\_phone) USING BTREE             |
| idx\_sent\_at           | KEY idx\_sent\_at (sent\_at) USING BTREE                             |
| idx\_source             | KEY idx\_source (source) USING BTREE                                 |
| idx\_status             | KEY idx\_status (status) USING BTREE                                 |
| PRIMARY                 | PRIMARY KEY (id) USING BTREE                                         |
| uk\_message\_id\_source | UNIQUE KEY uk\_message\_id\_source (message\_id, source) USING BTREE |
| uk\_uuid                | UNIQUE KEY uk\_uuid (uuid) USING BTREE                               |

## Relations

```mermaid
erDiagram


"tbl_sms_logs" {
  bigint_unsigned id PK
}
```

***

> Generated by [tbls](https://github.com/k1LoW/tbls)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.snapfix.com/engineering-reference/db/tables/tbl_sms_logs.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
