> For the complete documentation index, see [llms.txt](https://www.docpartner.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.docpartner.dev/en/api/sms-partner/send-sms/character-counter.md).

# Character counter

Estimate an SMS before sending: number of segments, detected encoding, unit price and total cost, based on your account's rate.

## URL

`POST` `https://api.smspartner.fr/v1/sms/estimate`

Rate limit: 30 requests / 30 seconds

## Parameters

<table><thead><tr><th width="220">Name</th><th>Value</th></tr></thead><tbody><tr><td><code>apiKey</code></td><td><a href="https://my.smspartner.fr/dashboard/api/paramaters">Your API key</a></td></tr><tr><td><code>text</code></td><td><strong>Required.</strong> Content of the message to estimate. 10,000 characters maximum.</td></tr><tr><td><code>country</code></td><td>Optional. ISO 3166-1 alpha-2 country code (e.g. <code>FR</code>, <code>BE</code>) used to determine the rate. Default value: <code>FR</code>.</td></tr></tbody></table>

{% hint style="info" %}
A message cannot exceed **10 SMS** (segments). Beyond that, the API returns an error.
{% endhint %}

## Example request

```json
{
    "apiKey": "xxx",
    "text": "Thanks for your order, delivery expected tomorrow before noon!",
    "country": "FR"
}
```

## Response

<table><thead><tr><th width="220">Field</th><th>Value</th></tr></thead><tbody><tr><td><code>sms_count</code></td><td>Number of SMS segments needed to send the message.</td></tr><tr><td><code>encoding</code></td><td>Detected encoding: <code>GSM-7</code> (standard alphabet) or <code>UCS-2</code> (Unicode characters, e.g. emojis, extended accents).</td></tr><tr><td><code>cost_per_sms</code></td><td>Unit price per SMS segment, based on your account's rate.</td></tr><tr><td><code>total_cost</code></td><td>Estimated total cost (<code>cost_per_sms</code> × <code>sms_count</code>).</td></tr><tr><td><code>is_unicode_required</code></td><td>Present and set to <code>true</code> only when the encoding is <code>UCS-2</code> (the message contains Unicode characters). Absent otherwise.</td></tr></tbody></table>

{% tabs %}
{% tab title="Response (UCS-2)" %}

```json
{
    "sms_count": 2,
    "encoding": "UCS-2",
    "cost_per_sms": 0.038,
    "total_cost": 0.076,
    "is_unicode_required": true
}
```

{% endtab %}

{% tab title="Response (GSM-7)" %}

```json
{
    "sms_count": 1,
    "encoding": "GSM-7",
    "cost_per_sms": 0.038,
    "total_cost": 0.038
}
```

{% endtab %}
{% endtabs %}

## Errors

On error, the response has the form `{ "success": false, "message": "..." }` with the corresponding HTTP status.

<table><thead><tr><th width="160">HTTP status</th><th>Case</th></tr></thead><tbody><tr><td><code>400</code></td><td>Invalid JSON, missing <code>text</code> parameter, <code>text</code> longer than 10,000 characters, or message exceeding 10 SMS.</td></tr><tr><td><code>401</code></td><td><code>apiKey</code> missing or invalid.</td></tr><tr><td><code>429</code></td><td>Rate limit exceeded (30 requests / 30 seconds).</td></tr></tbody></table>


---

# 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://www.docpartner.dev/en/api/sms-partner/send-sms/character-counter.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.
