# SMS records

For enabled projects and billing accounts, SMS records are generated daily and are available over [SFTP](sftp.md).

## SMS record specification

Enfonica SMS records are CSV files with the following specifications:

Property | Value
--|--
Header row | Yes
Delimiter | Comma (`,`)
Line ending style | Windows (`\r\n`)
Text qualifier | Double quote (`"`)
Encoding | UTF-8

## Conventions

The following conventions are used.

Property | Description
--|--
Date/time fields | Uses [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format in UTC.<br/><br/>For example: `2022-08-26T10:11:22.025Z`

## File structure

The following directory and file structure is used.

Property | Description
--|--
Directory | `/sms-records/` in SFTP.
File name | `YYYY-mm-dd.csv`<br/><br/>For example: `2022-08-25.csv` for messages on August 25, 2022.

## Time range of included data

Messages are included in the SMS record where the `CreateTime` of the message falls within the date of the file. While messages will generally be ordered by `ProjectId` and `CreateTime`, you should not rely on ordering within the file.

## Fields

The following fields are present in the SMS record.

Field | Description
--|--
ID | The unique identifier of the message. This is a 30 character, alphanumeric string.<br/><br/>For example: `kd8sore0at5emifrkh04p4foulugj4`
ProjectId | The ID of the project where the message was sent or received. This is up to 30 characters and can include lowercase alphanumeric characters and dash (`-`).<br/><br/>For example: `example-project`
CreateTime | The date and time that the message was created.
SendTime | The date and time that the message was accepted by the carrier. This is only set for outgoing messages that have been sent.
DeliverTime | The date and time that message delivery was confirmed. This is only set for messages where delivery confirmation was received.
Direction | The direction of the message. Possible values: `OUTGOING`, `INCOMING`.
From | The sender of the message. For outgoing messages, this is either a phone number in +E164 format or an alphanumeric sender ID. For incoming messages, this is the sender's phone number in +E164 format.<br/><br/>For example: `+61400000000` or `MyBrand`
To | The recipient of the message in +E164 format.<br/><br/>For example: `+61400000000`
Status | The status of the message.<br/><br/>Possible values:<ul><li>`QUEUED`: The message is queued for sending.</li><li>`SENDING`: The message is being sent to the carrier.</li><li>`SENT`: The message has been accepted by the carrier.</li><li>`FAILED`: The message could not be sent.</li><li>`DELIVERED`: The message was confirmed delivered to the recipient.</li><li>`UNDELIVERED`: The message was not delivered to the recipient.</li><li>`RECEIVED`: The message was received (incoming messages only).</li></ul>
Segments | The number of SMS segments that make up the message. A standard SMS message is 160 characters (GSM-7 encoding) or 70 characters (UCS-2 encoding). Messages exceeding this length are split into multiple segments.<br/><br/>For example: `1`
Encoding | The encoding of the message. Possible values: `GSM7`, `UCS2`.
SkuId | The ID of the SKU that was used to rate the message. A list of SKUs can be downloaded from the [pricing page](https://enfonica.com/pricing). This is only set for outgoing messages.<br/><br/>For example: `461C-87AB-7608`
Price | The price that was charged for the message as a decimal number. If the message was not billable, this field may be blank.<br/><br/>For example: `0.065`
CurrencyCode | The currency code of the charge. If the message was not billable, this field may be blank. The currency of all charges under a project or billing account will be the same and cannot change.<br/><br/>For example: `AUD`
ToCountryCode | The alpha-2 country code of the recipient's phone number.<br/><br/>For example: `AU`
