> 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/automate-your-gifts/retrieve-your-gyfti-campaigns.md).

# Retrieve your gyfti campaigns

## Retrieve user's trigger campaign

<mark style="color:blue;">`GET`</mark> `https://app.gyfti.fr/api/1.1/obj/Campaign`

#### Query Parameters

| Name            | Type    | Description                                       |
| --------------- | ------- | ------------------------------------------------- |
| key             | String  | The key to which you want to apply the constraint |
| constraint type | String  | the type of constraint to apply                   |
| value           | Varying | The Value the constraint should compare to        |
| cursor          | Number  | Start from item #                                 |
| limit           | String  | Show item until #                                 |
| sort\_field     | String  | The field you want to sort by                     |

#### Headers

| Name                                            | Type   | Description              |
| ----------------------------------------------- | ------ | ------------------------ |
| Authorization<mark style="color:red;">\*</mark> | String | 'Bearer  \[YOUR\_TOKEN]' |

{% tabs %}
{% tab title="200: OK Success" %}

```javascript
{
    "response": {
        "cursor": 0,
        "results": [
            {
                "Campaign_Name": "Test campaign",
                "Campaign Reason": "Fidélisation",
                "Start date": "03/01/2023 08:00 am",
                "Tag": [],
                "Created By": "user@email.com",
                "Created Date": "Mar 1, 2023 3:18 pm",
                "Modified Date": "Mar 1, 2023 3:18 pm",
                "Campaign Type": "trigger",
                "_id": "1651515982034x175783272039055360"
            },
}
```

{% endtab %}
{% endtabs %}

## Campaign data explained

You can these different **Data Types** to search for campaigns

| Data fields    | type      | Value                    |
| -------------- | --------- | ------------------------ |
| Campaign\_Name | text      | {YOUR\_CAMPAIGN\_NAME}   |
| Campaign Type  | text      | Trigger, directe trigger |
| Owner          | Unique Id | {OWNER\_UNIQUE\_ID}      |

**Campaign\_Name:** is the name of the campaign the user gave&#x20;

**Campaign Type: you should choose between 2 campaign types:**&#x20;

* **Trigger:** trigger campaigns are campaigns with an email experience sent to the recipient&#x20;
* **Trigger directe:** trigger directe campaigns are campaigns which create an order dispatched to the postal address added to the recipient&#x20;

**Owner:** is the user who created the campaign

**Unique id:** is the unique id of a campaign

## Getting a list of things and search

## Retrieve a list of email trigger campaigns

The email trigger campaign endpoint allows you to retrieve a list of Trigger campaigns as a type "email" from your account.

How do you know which campaign can be used as a trigger with a type "email"?

**Campaign Type** must be Trigger

#### Base url : <https://app.gyfti.fr/api/1.1/obj>/Campaign

#### Getting a list of things and search

Use this call to retrieve a list of things of a given type, optionally using search constraints.\
&#x20;\
Add parameters directly in the URL as a querystring (or in the body of the request). It can be `limit`, `cursor`, `constraints`, `sort_field`, and `descending`.\
&#x20;\
In most search requests, you will use field names. The logic behind the match between field names in the gyfti app and in the request is similar to the one that applies to types. The general rule to figure out the `field_name` for a given field is as follows:\
– Remove the spaces of the caption.\
– Use lowercase letters.\
&#x20;\
You can also use the name of the field that is returned in the objects. This is the way the field is represented in the app behind the scenes.\
&#x20;\
In the case where no field matches the field\_name of the request, the server will return a 400 error. If two fields for the current type match the `field_name`, the first one will be used.

#### **Pagination**

By default, all GET requests return the first 100 items in the list. Our API supports the parameters `cursor` and `limit` for pagination. Use `limit` to specify the number of items you want in the response. The default and maximum allowed is 100. Use `cursor` to specify where to start.\
&#x20;\
At the end of each GET response, three values are returned that let you know where you are in the list:\
– `cursor`: This is the rank of the first item in the list. It equals the cursor you sent, if any.\
– `count`: This is the number of items in the current response. It is the minimum between the actual length of the list and the limit you sent or 100 if you did not specify a limit.\
– `remaining`: This is the number of remaining items after the current response. Use this for the next call.

#### **Search Constraints**

Refine the list that is returned by the Data API with search constraints, exactly as you define a search in gyfti. To do so, pass a `constraints` parameter with the request. This parameter should be an array of constraints, e.g., objects with a `key`, `constraint_type`, and most of the time a `value`. If it is in the URL, it should be stringified and URL-encoded.\
\
`key`: This is the field name the constraint applies to. You can also use the reserved key `_all` for a full-text search in the database.\
\
`constraint_type`: This is the type of constraint you want to apply. It can be:

| Constraint Type                        | Description                                                               | Field Types                   |
| -------------------------------------- | ------------------------------------------------------------------------- | ----------------------------- |
| `equals` or `not equal`                | Use to test strict equality                                               | All field types               |
| `is_empty` or `is_not_empty`           | Use to test whether a thing's given field is empty or not                 | All field types               |
| `text contains` or `not text contains` | Use to test whether a text field contains a string, for text fields only. | Text fields only              |
| `greater than` or `less than`          | Use to compare a thing's field value relative to a string or number       | Text, number, and date fields |
| `in` or `not in`                       | Use to test whether a thing's field is in a list or not                   | All field types               |
| `contains` or `not contains`           | Use to test whether a list field contains an entry or not                 | List fields only              |
| `empty` or `not empty`                 | Use to test whether a list field is empty or not                          | List fields only              |

`value`: This is the value the constraint should compare to. It can be a string, number, list, etc., depending on the field type defined by the `key` in the current constraint. If the type of the value isn't correct, gyfti returns a 400 error, 'INVALID\_DATA.'\
&#x20;\
Constraints with an undefined `value` are ignored. Do not use '\_id' as a key for a constraint. Instead, use the call that retrieves a thing by ID. See above.

#### Example

For example, if you're looking for all 'campaign' whose 'Campaign Type' is 'Trigger' and 'Owner' is '1617009449761x480450913718632450' you will send a constraint parameter as follows:

| Key              |                                           |
| ---------------- | ----------------------------------------- |
| key              | Campaign Type, Owner                      |
| constraint\_type | equals, equals                            |
| value            | Trigger, 1617009449761x480450913718632450 |

```json
constraints = [ 
{ "key": "Campaign Type",
 "constraint_type": "equals",
 "value": "Trigger" 
},
{ "key": "Owner",
 "constraint_type": "equals",
 "value": "1617009449761x480450913718632450"
}
]
```

**The url should look like this :** \ <mark style="color:red;">`https://app.gyfti.fr/api/1.1/obj/campaign?constraints=[{"key":"Campaign Type","constraint_type":"equals","value":"Trigger"},{"key":"Owner","constraint_type":"equals","value":"1617009449761x480450913718632450"}]`</mark>

\
**Or URL-Encoded:**\ <mark style="color:red;">`https://app.gyfti.fr/api/1.1/obj/subanswers?constraints=%5B%7B%22key%22%3A%22type%22%2C%22constraint_type%22%3A%22`</mark>\ <mark style="color:red;">`equals%22%2C%22value%22%3A%22Trigger%22%7D%2C%7B%22key%22%3A%22Owner`</mark>\ <mark style="color:red;">`%22%2C%22constraint_type%22%3A%22equals%22%2C%22value%22%3A%221617009449761x480450913718632450%22%7D%5D`</mark><br>

## Retrieve a list of email trigger campaigns
