# Add Contact

## URL

<mark style="color:green;">`POST`</mark> `https://api.smspartner.fr/v1/contact/add`

#### **Required Parameters**

<table data-full-width="false"><thead><tr><th width="180">Name</th><th>Value</th></tr></thead><tbody><tr><td><code>apiKey</code></td><td><a href="https://my.smspartner.fr/dashboard/api">Your API key</a></td></tr><tr><td><code>groupId</code></td><td>The ID of the group to which the contact will be added</td></tr><tr><td><code>phoneNumber</code></td><td><p>Contact phone number.<br>It must be:</p><ul><li>In national format (06xxxxxxxx) or international format (+336xxxxxxxx) for French numbers</li><li>In international format (+496xxxxxxxx) for numbers outside France</li></ul></td></tr></tbody></table>

#### **Optional Parameters**

<table><thead><tr><th width="262">Name</th><th>Value</th></tr></thead><tbody><tr><td><code>firstname</code></td><td>First name (max 32 characters)</td></tr><tr><td><code>lastname</code></td><td>Last name (max 32 characters)</td></tr><tr><td><code>date</code></td><td>Date in YYYY-MM-DD format. Can be used for automatic sending (e.g., birthday)</td></tr><tr><td><code>url</code></td><td>URL, must start with http:// or https://</td></tr><tr><td><code>custom1</code></td><td>Custom field 1</td></tr><tr><td><code>custom2</code></td><td>Custom field 2</td></tr><tr><td><code>custom3</code></td><td>Custom field 3</td></tr><tr><td><code>custom4</code></td><td>Custom field 4</td></tr></tbody></table>

#### Request

{% tabs %}
{% tab title="Exemple" %}

```json
{
  "curl_command": {
    "method": "POST",
    "url": "http://api.smspartner.fr/v1/contact/add",
    "headers": {
      "Content-Type": "application/json"
    },
    "data": {
      "apiKey": "YOUR_API_KEY",
      "groupId": "ID GROUP",
      "contact": {
        "phoneNumber": "xxxxxxxxx",
        "firstname": "prénom",
        "lastname": "nom",
        "date": "YYYY-MM-DD",
        "shortUrlPartnr": "http://",
        "url": "http://",
        "custom1": "custom 1",
        "custom2": "custom 2",
        "custom3": "custom 3",
        "custom4": "custom 4"
      }
    }
  }
}
```

{% endtab %}
{% endtabs %}

#### **Réponse**

{% tabs %}
{% tab title="json" %}

```json
{
  "success": true,
  "code": 200,
  "contact": {
    "phoneNumber": "xxxxxxxx",
    "firstname": "FirstName",
    "lastname": "LastName",
    "date": "YYYY-MM-DD",
    "shortUrlPartnr": "http://",
    "url": "http://",
    "custom1": "custom 1",
    "custom2": "custom 2",
    "custom3": "custom 3",
    "custom4": "custom 4",
    "contactId": "CONTACT_ID"
  }
}
```

{% endtab %}
{% endtabs %}

#### Errors

{% tabs %}
{% tab title="json" %}

```json
{
  "success": false,
  "code": 10,
  "message": "Invalid API key"
}
```

{% endtab %}
{% endtabs %}

**Error Codes**

| Response Code | Message                                      |
| ------------- | -------------------------------------------- |
| 1             | groupId is required                          |
| 2             | Contact information is required              |
| 10            | API key is required                          |
| 15            | The phone number already exists in the group |


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://www.docpartner.dev/en/api/sms-partner/contact-management/add-contact.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
