> For the complete documentation index, see [llms.txt](https://developer.gyfti.fr/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.gyfti.fr/gyfti-api/api-campagne.md).

# API Campagne

## Add Contacts to Campaigns API

Use the Gyfti API to add contacts to your campaigns.

This API allows you to send gifts to your contacts via your Gyfti campaigns programmatically.

***

### 1. Retrieve the campaign ID

Before adding a contact to a campaign, you need to retrieve the campaign’s unique identifier.

Once the campaign has been published, open the campaign details page in Gyfti. You can find the campaign ID directly in the page URL.

The URL will follow this format:

```http
https://app.gyfti.fr/v3_offreur?tab=campagnes&campaign={campaign_id}&sub=recap
```

The value after `campaign=` is the campaign ID.

For example:

```http
https://app.gyfti.fr/v3_offreur?tab=campagnes&campaign=abc123&sub=recap
```

In this example, the campaign ID is:

```
abc123
```

***

### 2. Add a contact to a campaign

Use this endpoint to add a contact to an existing campaign.

#### Endpoint

```http
POST https://app.gyfti.fr/api/1.1/wf/add_contact_to_campaign
```

#### Headers

```http
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json
```

[Get you API Key from your setting page ](https://app.gyfti.fr/reglages/campagne?p=integrations\&tab=api-campagne)

#### Request body

```json
{
  "campaign_id": "{campaign_id}",
  "user_email": "text",
  "contact_first_name": "text",
  "contact_last_name": "text",
  "contact_email": "text",

  "contact_city": "text",
  "contact_postal_code": "text",
  "contact_country": "text",
  "contact_address": "text",
  "contact_phone": "text",
  "contact_additional_address": "text",
  "contact_job_title": "text"
}
```

#### Parameters

| Parameter                    |   Type | Required | Description                                     |
| ---------------------------- | -----: | :------: | ----------------------------------------------- |
| `campaign_id`                | string |    Yes   | The unique identifier of the campaign.          |
| `user_email`                 | string |    Yes   | The email address of the user sending the gift. |
| `contact_first_name`         | string |    Yes   | The contact’s first name.                       |
| `contact_last_name`          | string |    Yes   | The contact’s last name.                        |
| `contact_email`              | string |    Yes   | The contact’s email address.                    |
| `contact_city`               | string |    No    | The contact’s city.                             |
| `contact_postal_code`        | string |    No    | The contact’s postal code.                      |
| `contact_country`            | string |    No    | The contact’s country.                          |
| `contact_address`            | string |    No    | The contact’s address.                          |
| `contact_phone`              | string |    No    | The contact’s phone number.                     |
| `contact_additional_address` | string |    No    | Additional address information for the contact. |
| `contact_job_title`          | string |    No    | The contact’s job title.                        |

#### Example request

```bash
curl -X POST https://app.gyfti.fr/api/1.1/wf/add_contact_to_campaign \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "campaign_id": "abc123",
    "user_email": "sender@example.com",
    "contact_first_name": "John",
    "contact_last_name": "Doe",
    "contact_email": "john.doe@example.com",

    "contact_city": "Paris",
    "contact_postal_code": "75001",
    "contact_country": "France",
    "contact_address": "10 Rue de Rivoli",
    "contact_phone": "+33123456789",
    "contact_additional_address": "Apartment 4B",
    "contact_job_title": "Marketing Manager"
  }'
```

#### Example response

```json
{
  "message": "Le contact a été ajouté à votre campagne: {nom du campagne}"
}
```
