# Public API

{% hint style="success" %}
Through your AB Tasty account, you can generate credentials linked to roles for the AB Tasty Public API. If you are a partner and want to build a program with our Public API, please contact us at <product@abtasty.com>
{% endhint %}

### What will you be able to do with our Public API?

Thanks to our Public API and depending of the role of your credentials you will be able to do several thing such as:

* Get the tests information
* Manage status of every tests
* Manage users of your account
* Update the AB Tasty script
* Clear the AB Tasty script
* Get the framework checksum

{% hint style="info" %}
Each use case need specific access delivered through your AB Tasty's account settings. Please ask your admin to grant you with the correct access.
{% endhint %}

## Quick Start

First of all, an admin of your account have to ask AB Tasty for Public API credentials.

## Authentication

`POST https://api.abtasty.com/oauth/v2/token`

{% tabs %}
{% tab title="Request" %}
`https://api.abtasty.com/oauth/v2/token`

```javascript
{
  "client_id":"XXXXXX",
  "client_secret":"XXXXXX",
  "grant_type":"client_credentials"
}
```

{% endtab %}

{% tab title="Response" %}

```javascript
{
  "access_token": "12345678QZSEDRFGHJK234567SDFGH234567SDF",
  "expires_in": 43200,
  "token_type": "bearer",
  "scope": "XXX"
}
```

{% endtab %}
{% endtabs %}

**Arguments**

| Parameter      | Type   | Required | Format                                                           | Description                         |
| -------------- | ------ | -------- | ---------------------------------------------------------------- | ----------------------------------- |
| client\_id     | string | true     | Example: "2\_xe68dghl0ghoo42vay79rytcv"                          | The client ID                       |
| client\_secret | string | true     | Example: "34g7fpjzq2gww08w84owgrghuowk4goog4kkwkk4s0c057f48kksc" | The client secret                   |
| grant\_type    | string | true     | Value to use: "client\_credentials"                              | The grant type: client\_credentials |

**Headers**

| Name         | Required | Value              |
| ------------ | -------- | ------------------ |
| Content-Type | true     | `application/json` |
| Accept       | true     | `application/json` |

## Get my tests information

With this role you will be able to:

* [Get all tests of the account](#get-all-tests-of-the-account)
* [Get information of one test](#get-information-of-one-test)
* [Get the variation of a test](#get-the-variations-of-a-test)
* [Get one specific variation](#get-one-specific-variation)
* [Get modifications of a variation](#get-modifications-of-a-variation)
* [Get every links of the tests with third party tool](#get-every-links-of-the-tests-with-third-party-tool)
* [Get one specific link of the test with a third party tool](#get-one-specific-link-of-the-test-with-a-third-party-tool)
* [Get events set up in a test](#get-events-set-up-in-a-test)
* [Get account's tests statistics](#get-account's-tests-statistics)

### Get all tests of the account

`GET /api/core/accounts/[account_id]/tests`

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

```
https://api.abtasty.com/api/core/accounts/41902/tests?filter[type][]=ab&filter[type][]=mastersegment&filter[active]=1
```

{% endtab %}

{% tab title="Response" %}

```json
{
  "page": 1,
  "limit": 10,
  "pages": 1,
  "total": 2,
  "_links": {
    "self": {
        "href": "/api/core/accounts/41902/tests?filter%5Btype%5D%5B0%5D=ab&filter%5Btype%5D%5B1%5D=mastersegment&filter%5Bactive%5D=1&_page=1&_max_per_page=10"
    },
    "first": {
        "href": "/api/core/accounts/41902/tests?filter%5Btype%5D%5B0%5D=ab&filter%5Btype%5D%5B1%5D=mastersegment&filter%5Bactive%5D=1&_page=1&_max_per_page=10"
    },
    "last": {
        "href": "/api/core/accounts/41902/tests?filter%5Btype%5D%5B0%5D=ab&filter%5Btype%5D%5B1%5D=mastersegment&filter%5Bactive%5D=1&_page=1&_max_per_page=10"
    }
  },
  "_embedded": {
    "items": [
        {
            "type": "mastersegment",
            "labels": [
                "silviya",
                "Gil"
            ],
            "start_datetime": 0,
            "stop_datetime": 0,
            "state": "play",
            "preprod": false,
            "tunnel_parent": 0,
            "test_visitor_count": 9,
            "id": 365111,
            "name": "Gil Test",
            "traffic": 100,
            "active": true,
            "url": "master",
            "ga": 0,
            "omniture": 0,
            "at_internet": 0,
            "report_token": "c2ff5d513d9f78c7087cf53263d6ba53",
            "last_pause_timestamp": 0,
            "last_play_timestamp": 1542811579,
            "script_verified": false,
            "global_code": "",
            "autodes_goal": "",
            "autodes_goal_last_visitors": 0,
            "start_stop_timezone": "Europe/Brussels",
            "data_collect_version": 3,
            "creation_date": "2018-11-21T15:43:18+0100",
            "useragent": "",
            "ht_access": "",
            "creator_id": 47121,
            "visitors_count": 0,
            "original_visitors_count": 0,
            "test_rank": 0,
            "history_calc_mode": "new",
            "targeting_event_mode": "fastest",
            "dynamic_alloc_goal_id": null,
            "source_code": null,
            "description": null,
            "dynamic_alloc_modulation": 50,
            "reference_variation_id": null,
            "audience_id": null,
            "_links": {
                "self": {
                    "href": "/api/core/accounts/41902/tests/365111"
                },
                "tool_links": {
                    "href": "/api/core/accounts/41902/tests/365111/toollinks"
                },
                "variations": {
                    "href": "/api/core/accounts/41902/tests/365111/variations"
                },
                "goals": {
                    "href": "/api/core/accounts/41902/tests/365111/goals"
                },
                "nested": {
                    "href": "/api/interface/accounts/41902/tests/365111/nested"
                }
            },
            "_embedded": {
                "account": {
                    "id": 41902
                },
                "folder": null,
            }
        },
        {
            "type": "ab",
            "labels": [
                "arthur.charbit"
            ],
            "start_datetime": 0,
            "stop_datetime": 0,
            "state": "play",
            "preprod": false,
            "tunnel_parent": 0,
            "test_visitor_count": 0,
            "id": 367659,
            "name": "test",
            "traffic": 50,
            "active": true,
            "url": "http://abtastylab.com/60511af14f5e48764b83d36ddb8ece5a/",
            "ga": 0,
            "omniture": 0,
            "at_internet": 0,
            "report_token": "0bb21bc01326175ec51e16c17e0e396f",
            "last_pause_timestamp": 0,
            "last_play_timestamp": 1545921356,
            "script_verified": false,
            "global_code": "",
            "autodes_goal": "",
            "autodes_goal_last_visitors": 0,
            "start_stop_timezone": "Europe/Brussels",
            "data_collect_version": 3,
            "creation_date": "2018-11-26T11:57:12+0100",
            "useragent": "",
            "ht_access": "",
            "creator_id": 43571,
            "visitors_count": 0,
            "original_visitors_count": 0,
            "test_rank": 0,
            "history_calc_mode": "new",
            "targeting_event_mode": "fastest",
            "dynamic_alloc_goal_id": null,
            "source_code": null,
            "description": null,
            "dynamic_alloc_modulation": 50,
            "reference_variation_id": null,
            "audience_id": "c82c4865-e2d0-49b9-b0b9-7c74c59a826f",
            "_links": {
                "self": {
                    "href": "/api/core/accounts/41902/tests/367659"
                },
                "tool_links": {
                    "href": "/api/core/accounts/41902/tests/367659/toollinks"
                },
                "variations": {
                    "href": "/api/core/accounts/41902/tests/367659/variations"
                },
                "goals": {
                    "href": "/api/core/accounts/41902/tests/367659/goals"
                },
                "nested": {
                    "href": "/api/interface/accounts/41902/tests/367659/nested"
                }
            },
            "_embedded": {
                "account": {
                    "id": 41902
                },
                "folder": null,
            }
        }
    ]
  }
}
```

{% endtab %}
{% endtabs %}

**Requirements**

| Name        | Requirements | Type    | Description       |
| ----------- | ------------ | ------- | ----------------- |
| account\_id | \d+          | integer | ID of the account |

**Filters**

| Name                     | Datatype | Description                                   | Pattern                                                                                                   | Default |
| ------------------------ | -------- | --------------------------------------------- | --------------------------------------------------------------------------------------------------------- | ------- |
| \_page                   | integer  | Page of the collection                        |                                                                                                           | 10      |
| \_max\_per\_page         | integer  | Limit of items per page                       |                                                                                                           | 10      |
| filter\[name]            | string   | Search by name of the test                    |                                                                                                           |         |
| filter\[name\_or\_url]   | string   | Search by name and url of the test            |                                                                                                           |         |
| filter\[search]          | string   | Search by name/url/id of the test             |                                                                                                           |         |
| filter\[parent]\[]       | integer  | Search by parent id (0 for no parent)         |                                                                                                           |         |
| filter\[type]\[]         |          | Search by test type                           | ab/mastersegment/predictive/segmentation/ tunnel/mvt/multipage/ multivariate/subsegment/mobileapp/heatmap |         |
| filter\[folder]\[]       | integer  | Search by folder id (0 for no folder)         |                                                                                                           |         |
| filter\[active]          |          | 0 => pause ; 1 => play                        | (0/1)                                                                                                     |         |
| filter\[is\_preprod]     |          | If is set only preprod test will be returned  |                                                                                                           |         |
| filter\[is\_schedule]    |          | 0 -> test not schedule ; 1 -> test schedule   | (0/1)                                                                                                     |         |
| filter\[exclude\_tag]\[] | string   | exclude specific tag of the collection        |                                                                                                           |         |
| filter\[tag]\[]          | string   | only test with specific tag of the collection |                                                                                                           |         |
| filter\[\_order]\[id]    |          | Order collecion by id                         | (ASC/DESC)                                                                                                |         |
| filter\[\_order]\[name]  |          | Order collection by name                      | (ASC/DESC)                                                                                                |         |

**Headers**

| Name            | Required | Description                                                    |
| --------------- | -------- | -------------------------------------------------------------- |
| Content-Type    | true     | Format of the request                                          |
| Authorization   | true     | User token (example: Bearer \[token]                           |
| Accept-Language | false    | Language use for the response (user setting can override this) |

### Get information of one test

`GET /api/v1/accounts/[account_id]/tests/[test_id]`

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

```
https://api.abtasty.com/api/v1/accounts/41902/tests/381296
```

{% endtab %}

{% tab title="Response" %}

```json
{
    "type": "ab",
    "labels": [
        "arthur.charbit"
    ],
    "start_datetime": 0,
    "stop_datetime": 0,
    "state": "pause",
    "preprod": false,
    "tunnel_parent": 0,
    "test_visitor_count": 0,
    "id": 381296,
    "name": "Public API Test",
    "traffic": 50,
    "active": false,
    "url": "http://abtastylab.com/60511af14f5e48764b83d36ddb8ece5a/",
    "ga": 0,
    "omniture": 0,
    "at_internet": 0,
    "report_token": "3b5975f6df992ae275129514bde82a9f",
    "last_pause_timestamp": 0,
    "last_play_timestamp": null,
    "script_verified": false,
    "global_code": "",
    "autodes_goal": "",
    "autodes_goal_last_visitors": 0,
    "start_stop_timezone": "Europe/Brussels",
    "data_collect_version": 3,
    "creation_date": "2018-12-28T16:18:29+0100",
    "useragent": "",
    "ht_access": "",
    "creator_id": 43571,
    "visitors_count": 0,
    "original_visitors_count": 0,
    "test_rank": 0,
    "history_calc_mode": "new",
    "targeting_event_mode": "fastest",
    "dynamic_alloc_goal_id": null,
    "source_code": null,
    "description": null,
    "dynamic_alloc_modulation": 50,
    "reference_variation_id": null,
    "audience_id": "987a7647-e378-487a-bbb1-6353a4501db1",
    "_links": {
        "self": {
            "href": "/api/v1/accounts/41902/tests/381296"
        },
        "tool_links": {
            "href": "/api/core/accounts/41902/tests/381296/toollinks"
        },
        "variations": {
            "href": "/api/core/accounts/41902/tests/381296/variations"
        },
        "goals": {
            "href": "/api/core/accounts/41902/tests/381296/goals"
        },
        "nested": {
            "href": "/api/interface/accounts/41902/tests/381296/nested"
        }
    },
    "_embedded": {
        "account": {
            "id": 41902
        },
        "folder": null,
    }
}

```

{% endtab %}
{% endtabs %}

**Requirements**

| Name        | Requirements | Type    | Description       |
| ----------- | ------------ | ------- | ----------------- |
| account\_id | \d+          | integer | ID of the account |
| test\_id    | \d+          | Integer | ID of the test    |

**Filters**

| Name             | Datatype | Description             | Pattern | Default |
| ---------------- | -------- | ----------------------- | ------- | ------- |
| \_max\_per\_page | integer  | Limit of items per page |         | 10      |
| \_page           | integer  | Page of the collection  |         | 10      |

**Headers**

| Name            | Required | Description                                                    |
| --------------- | -------- | -------------------------------------------------------------- |
| Content-Type    | true     | Format of the request                                          |
| Authorization   | true     | User token (example: Bearer \[token]                           |
| Accept-Language | false    | Language use for the response (user setting can override this) |

### Get the variations of a test

`GET /api/core/accounts/[account_id]/tests/[test_id]/variations`

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

```
https://api.abtasty.com/api/core/accounts/41902/tests/381301/variations
```

{% endtab %}

{% tab title="Response" %}

```json
[
    {
        "id": 0,
        "name": "Original",
        "type": "onthefly",
        "traffic": 50
    },
    {
        "id": 491035,
        "name": "Variation 1",
        "traffic": 50,
        "type": "onthefly",
        "description": null
    }
]
```

{% endtab %}
{% endtabs %}

**Requirements**

| Name        | Requirements | Type    | Description       |
| ----------- | ------------ | ------- | ----------------- |
| account\_id | \d+          | integer | ID of the account |
| test\_id    | \d+          | Integer | ID of the test    |

**Headers**

| Name            | Required | Description                                                    |
| --------------- | -------- | -------------------------------------------------------------- |
| Content-Type    | true     | Format of the request                                          |
| Authorization   | true     | User token (example: Bearer \[token]                           |
| Accept-Language | false    | Language use for the response (user setting can override this) |

### Get one specific variation

`GET /api/core/accounts/[account_id]/tests/[test_id]/variations/[variation_id]`

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

```
https://api.abtasty.com/api/core/accounts/41902/tests/381301/variations/491035
```

{% endtab %}

{% tab title="Response" %}

```json
{
    "id": 491035,
    "name": "Variation 1",
    "description": null,
    "traffic": 50,
    "type": "onthefly",
    "_links": {
        "self": {
            "href": "/api/core/accounts/41902/tests/381301/variations/491035"
        }
    }
}
```

{% endtab %}
{% endtabs %}

**Requirements**

| Name        | Requirements | Type    | Description       |
| ----------- | ------------ | ------- | ----------------- |
| account\_id | \d+          | integer | ID of the account |
| test\_id    | \d+          | Integer | ID of the test    |

**Headers**

| Name            | Required | Description                                                    |
| --------------- | -------- | -------------------------------------------------------------- |
| Content-Type    | true     | Format of the request                                          |
| Authorization   | true     | User token (example: Bearer \[token]                           |
| Accept-Language | false    | Language use for the response (user setting can override this) |

### Get modifications of a variation

`GET /api/core/accounts/[account_id]/tests/[test_id]/variations/[variation_id]/modifications`

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

```
https://api.abtasty.com/api/core/accounts/41902/tests/381301/variations/491035/modifications
```

{% endtab %}

{% tab title="Response" %}

```json
{
    "page": 1,
    "limit": 10,
    "pages": 1,
    "total": 1,
    "_links": {
        "self": {
            "href": "/api/core/accounts/41902/tests/381301/variations/491035/modifications?_page=1&_max_per_page=10"
        },
        "first": {
            "href": "/api/core/accounts/41902/tests/381301/variations/491035/modifications?_page=1&_max_per_page=10"
        },
        "last": {
            "href": "/api/core/accounts/41902/tests/381301/variations/491035/modifications?_page=1&_max_per_page=10"
        }
    },
    "_embedded": {
        "items": [
            {
                "use_modification_engine": true,
                "id": 2064015,
                "selector": "#myCarousel .active IMG",
                "type": "hideCSS",
                "value": "#myCarousel .active IMG {display:none!important;}",
                "name": "",
                "recursive": "no",
                "value_engine": "",
                "_links": {
                    "self": {
                        "href": "/api/core/accounts/41902/tests/381301/variations/491035/modifications/2064015"
                    }
                }
            }
        ]
    }
}
```

{% endtab %}
{% endtabs %}

**Requirements**

| Name          | Requirements | Type    | Description         |
| ------------- | ------------ | ------- | ------------------- |
| account\_id   | \d+          | integer | ID of the account   |
| test\_id      | \d+          | Integer | ID of the test      |
| variation\_id | \d+          | integer | ID of the variation |

**Filters**

| Name               | Datatype | Description                             | Pattern | Default |
| ------------------ | -------- | --------------------------------------- | ------- | ------- |
| \_max\_per\_page   | integer  | Limit of items per page                 |         | 10      |
| \_page             | integer  | Page of the collection                  |         | 10      |
| filter\[Operation] | string   | Search by operation of the modification |         |         |

**Headers**

| Name            | Required | Description                                                    |
| --------------- | -------- | -------------------------------------------------------------- |
| Content-Type    | true     | Format of the request                                          |
| Authorization   | true     | User token (example: Bearer \[token]                           |
| Accept-Language | false    | Language use for the response (user setting can override this) |

### Get a specific modification of a variation

`GET /api/core/accounts/[account_id]/tests/[test_id]/variations/[variation_id]/modifications/[modification_id]`

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

```
https://api.abtasty.com/api/core/accounts/41902/tests/381301/variations/491035/modifications/2064015
```

{% endtab %}

{% tab title="Response" %}

```json
{
    "use_modification_engine": true,
    "id": 2064015,
    "selector": "#myCarousel .active IMG",
    "type": "hideCSS",
    "value": "#myCarousel .active IMG {display:none!important;}",
    "name": "",
    "recursive": "no",
    "value_engine": "",
    "_links": {
        "self": {
            "href": "/api/core/accounts/41902/tests/381301/variations/491035/modifications/2064015"
        }
    }
}
```

{% endtab %}
{% endtabs %}

**Requirements**

| Name             | Requirements | Type    | Description            |
| ---------------- | ------------ | ------- | ---------------------- |
| account\_id      | \d+          | integer | ID of the account      |
| test\_id         | \d+          | Integer | ID of the test         |
| variation\_id    | \d+          | integer | ID of the variation    |
| modification\_id | \d+          | Integer | ID of the modification |

**Headers**

| Name            | Required | Description                                                    |
| --------------- | -------- | -------------------------------------------------------------- |
| Content-Type    | true     | Format of the request                                          |
| Authorization   | true     | User token (example: Bearer \[token]                           |
| Accept-Language | false    | Language use for the response (user setting can override this) |

### Get every links of the tests with third party tool

`GET /api/core/accounts/[account_id]/tests/[test_id]/toollinks`

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

```
https://api.abtasty.com/api/core/accounts/41902/tests/381301/toollinks
```

{% endtab %}

{% tab title="Response" %}

```json
{
    "page": 1,
    "limit": 10,
    "pages": 1,
    "total": 2,
    "_links": {
        "self": {
            "href": "/api/core/accounts/41902/tests/381301/toollinks?_page=1&_max_per_page=10"
        },
        "first": {
            "href": "/api/core/accounts/41902/tests/381301/toollinks?_page=1&_max_per_page=10"
        },
        "last": {
            "href": "/api/core/accounts/41902/tests/381301/toollinks?_page=1&_max_per_page=10"
        }
    },
    "_embedded": {
        "items": [
            {
                "id": 114112,
                "name": "Universal Analytics",
                "value": "12",
                "from_account": 1,
                "custom_tracker": null,
                "_links": {
                    "self": {
                        "href": "/api/core/accounts/41902/tests/381301/toollinks/114112"
                    }
                }
            },
            {
                "id": 114115,
                "name": "ATInternetSmartTag",
                "value": "10",
                "from_account": 0,
                "custom_tracker": null,
                "_links": {
                    "self": {
                        "href": "/api/core/accounts/41902/tests/381301/toollinks/114115"
                    }
                }
            }
        ]
    }
}
```

{% endtab %}
{% endtabs %}

**Requirements**

| Name        | Requirements | Type    | Description       |
| ----------- | ------------ | ------- | ----------------- |
| account\_id | \d+          | integer | ID of the account |
| test\_id    | \d+          | Integer | ID of the test    |

**Filters**

| Name             | Datatype | Description             | Default |
| ---------------- | -------- | ----------------------- | ------- |
| \_page           | integer  | Page of the collection  | 1       |
| \_max\_per\_page | integer  | Limit of items per page | 10      |

**Headers**

| Name            | Required | Description                                                    |
| --------------- | -------- | -------------------------------------------------------------- |
| Content-Type    | true     | Format of the request                                          |
| Authorization   | true     | User token (example: Bearer \[token]                           |
| Accept-Language | false    | Language use for the response (user setting can override this) |

### Get one specific link of the test with a third party tool

`GET /api/core/accounts/[account_id]/tests/[test_id]/toollinks/[toollinks_id]`

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

```
https://api.abtasty.com/api/core/accounts/41902/tests/381301/toollinks/114115
```

{% endtab %}

{% tab title="Response" %}

```json
{
    "id": 114115,
    "name": "ATInternetSmartTag",
    "value": "10",
    "from_account": 0,
    "custom_tracker": null,
    "_links": {
        "self": {
            "href": "/api/core/accounts/41902/tests/381301/toollinks/114115"
        }
    }
}
```

{% endtab %}
{% endtabs %}

**Requirements**

| Name          | Requirements | Type    | Description           |
| ------------- | ------------ | ------- | --------------------- |
| account\_id   | \d+          | integer | ID of the account     |
| test\_id      | \d+          | Integer | ID of the test        |
| toollinks\_id | \d+          | Integer | ID of the tool linked |

**Headers**

| Name            | Required | Description                                                    |
| --------------- | -------- | -------------------------------------------------------------- |
| Content-Type    | true     | Format of the request                                          |
| Authorization   | true     | User token (example: Bearer \[token]                           |
| Accept-Language | false    | Language use for the response (user setting can override this) |

### Get events set up in a test

`GET /api/core/accounts/[account_id]/tests/[test_id]/global_modifications`

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

```
https://api.abtasty.com/api/core/accounts/41902/tests/381301/global_modifications
```

{% endtab %}

{% tab title="Response" %}

```json
{
    "page": 1,
    "limit": 10,
    "pages": 1,
    "total": 1,
    "_links": {
        "self": {
            "href": "/api/core/accounts/41902/tests/381301/global_modifications?_page=1&_max_per_page=10"
        },
        "first": {
            "href": "/api/core/accounts/41902/tests/381301/global_modifications?_page=1&_max_per_page=10"
        },
        "last": {
            "href": "/api/core/accounts/41902/tests/381301/global_modifications?_page=1&_max_per_page=10"
        }
    },
    "_embedded": {
        "items": [
            {
                "id": 162007,
                "type": "actionTracking",
                "config": "AT",
                "value": "{\"name\":\"AT \",\"event\":\"mousedown\",\"data\":\"\",\"elementSelector\":\"#main .text-center:nth-child(4) H1\"}",
                "_links": {
                    "self": {
                        "href": "/api/core/accounts/41902/tests/381301/global_modifications/162007"
                    }
                }
            }
        ]
    }
}
```

{% endtab %}
{% endtabs %}

**Requirements**

| Name        | Requirements | Type    | Description       |
| ----------- | ------------ | ------- | ----------------- |
| account\_id | \d+          | integer | ID of the account |
| test\_id    | \d+          | Integer | ID of the test    |

**Filters**

| Name                  | Datatype | Description                                                | Pattern    | Default      |
| --------------------- | -------- | ---------------------------------------------------------- | ---------- | ------------ |
| \_page                | integer  | Page of the collection                                     |            | 1            |
| \_max\_per\_page      | integer  | Limit of items per page                                    |            | 10           |
| filter\[type]         | string   | Type of the global modification (plugin or actionTracking) |            | A valid type |
| filter\[\_order]\[id] |          | Order collection by id                                     | (ASC/DESC) |              |

**Headers**

| Name            | Required | Description                                                    |
| --------------- | -------- | -------------------------------------------------------------- |
| Content-Type    | true     | Format of the request                                          |
| Authorization   | true     | User token (example: Bearer \[token]                           |
| Accept-Language | false    | Language use for the response (user setting can override this) |

### Get account's tests statistics

`GET /api/core/accounts/[account_id]/general_statistics`

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

```
https://api.abtasty.com/api/core/accounts/41902/general_statistics
```

{% endtab %}

{% tab title="Response" %}

```json
{
    "campaign_states": {
        "ab": {
            "running": 1,
            "paused": 381
        },
        "multivariate": {
            "running": 0,
            "paused": 16
        },
        "multipage": {
            "running": 0,
            "paused": 68
        },
        "predictive": {
            "running": 0,
            "paused": 22
        },
        "byapi": {
            "running": 0,
            "paused": 0
        },
        "personalization": {
            "running": 0,
            "paused": 97
        }
    },
    "count_collaborators": 35,
    "count_collaborators_connections": 5,
    "started_experiments": [
        {
            "month_year": "1-2018",
            "count_visitors": "2467",
            "count_tests": "1"
        }
    ],
    "created_experiments": [
        {
            "month_year": "1-2019",
            "count_visitors": "38",
            "count_tests": "13",
            "avg_visitors": "3"
        },
        {
            "month_year": "12-2018",
            "count_visitors": "50",
            "count_tests": "11",
            "avg_visitors": "5"
        }
    ],
    "played_experiments": [
        {
            "month_year": "12-2018",
            "count_visitors": "50",
            "count_tests": "1"
        }
    ],
}
```

{% endtab %}
{% endtabs %}

**Requirements**

| Name        | Requirements | Type    | Description       |
| ----------- | ------------ | ------- | ----------------- |
| account\_id | \d+          | integer | ID of the account |

**Headers**

| Name            | Required | Description                                                    |
| --------------- | -------- | -------------------------------------------------------------- |
| Content-Type    | true     | Format of the request                                          |
| Authorization   | true     | User token (example: Bearer \[token]                           |
| Accept-Language | false    | Language use for the response (user setting can override this) |

## Manage my tests

With this role you will be able to update status of any campaign.\
All known statuses of the campaign: `draft`, `ready_to_launch`, `play`, `pause`, `in_qa`, `analysis`, `interrupted`, `archive`, `ended`.\
For more information about statuses, please visit [this page](/web-experimentation-and-personalization/campaign-creation-and-dashboard/campaign-statuses.md)

`PATCH /api/v1/accounts/[account_id]/tests/[test_id]`

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

```
https://api.abtasty.com/api/v1/accounts/41902/tests/381301
```

{% endtab %}
{% endtabs %}

```
{
  "status":"play"
}
```

> if everything was going well, it will return a success response with a 200.

**Requirements**

| Name        | Requirements | Type    | Description       |
| ----------- | ------------ | ------- | ----------------- |
| account\_id | \d+          | integer | ID of the account |
| test\_id    | \d+          | Integer | ID of the test    |

**Allowed transitions**

| <sub>from</sub>\\<sup>to</sup> | draft | ready\_to\_launch | play | pause | in\_qa | analysis | archive | ended | interrupted |
| ------------------------------ | ----- | ----------------- | ---- | ----- | ------ | -------- | ------- | ----- | ----------- |
| **draft**                      | ❌     | ✅                 | ✅    | ❌     | ✅      | ❌        | ✅       | ❌     | ❌           |
| **ready\_to\_launch**          | ✅     | ❌                 | ✅    | ✅     | ✅      | ❌        | ✅       | ❌     | ❌           |
| **play**                       | ❌     | ❌                 | ❌    | ✅     | ✅      | ✅        | ✅       | ✅     | ❌           |
| **pause**                      | ❌     | ✅                 | ✅    | ❌     | ✅      | ✅        | ✅       | ✅     | ❌           |
| **in\_qa**                     | ✅     | ✅                 | ✅    | ✅     | ❌      | ❌        | ✅       | ❌     | ❌           |
| **analysis**                   | ❌     | ❌                 | ✅    | ❌     | ❌      | ❌        | ✅       | ✅     | ❌           |
| **archive**                    | ✅     | ❌                 | ❌    | ✅     | ❌      | ❌        | ❌       | ❌     | ❌           |
| **ended**                      | ❌     | ❌                 | ✅    | ❌     | ❌      | ✅        | ✅       | ❌     | ❌           |
| **interrupted**                | ❌     | ❌                 | ✅    | ❌     | ✅      | ✅        | ✅       | ✅     | ❌           |

**Headers**

| Name            | Required | Description                                                    |
| --------------- | -------- | -------------------------------------------------------------- |
| Content-Type    | true     | Format of the request                                          |
| Authorization   | true     | User token (example: Bearer \[token]                           |
| Accept-Language | false    | Language use for the response (user setting can override this) |

## Manage AB Tasty's users of my account

With this role you will be able to:

* [Get all AB Tasty's users of the account](#get-all-users-of-my-account)
* [Get specific information about an AB Tasty user](#get-specific-information-about-a-user)
* [Give access to a user](#give-access-to-a-user)
* [Revoke access to a user](#revoke-access-to-a-user)

### Get all AB Tasty's users of my account

`GET /api/core/accounts/[account_id]/membership`

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

```
https://api.abtasty.com/api/core/accounts/41902/membership?_max_per_page=1
```

{% endtab %}

{% tab title="Response" %}

```json
{
    "page": 1,
    "limit": 1,
    "pages": 34,
    "total": 34,
    "_links": {
        "self": {
            "href": "/api/core/accounts/41902/membership?_page=1&_max_per_page=1"
        },
        "first": {
            "href": "/api/core/accounts/41902/membership?_page=1&_max_per_page=1"
        },
        "last": {
            "href": "/api/core/accounts/41902/membership?_page=34&_max_per_page=1"
        },
        "next": {
            "href": "/api/core/accounts/41902/membership?_page=2&_max_per_page=1"
        }
    },
    "_embedded": {
        "items": [
            {
                "id": 80397,
                "role": "admin",
                "_links": {
                    "self": {
                        "href": "/api/core/accounts/41902/membership/80397"
                    },
                    "account": {
                        "href": "/api/core/accounts/41902"
                    }
                },
                "_embedded": {
                    "user": {
                        "id": 2021,
                        "email": "user@abtasty.com",
                        "lastname": "XXX",
                        "firstname": "YYY",
                        "creation_date": "2012-07-24T18:10:33+0200",
                        "connection_count": 49708,
                        "last_login_time": "2019-02-14T09:50:39+0100",
                        "_links": {
                            "self": {
                                "href": "/api/core/users/2021"
                            }
                        },
                        "_embedded": {
                            "has_multiple_accounts": true
                        }
                    }
                }
            }
        ]
    }
}
```

{% endtab %}
{% endtabs %}

> if you correctly have access to the account, it will return a 200.

**Requirements**

| Name        | Requirements | Type    | Description       |
| ----------- | ------------ | ------- | ----------------- |
| account\_id | \d+          | integer | ID of the account |

**Filters**

| Name             | Datatype | Description             | Pattern | Default |
| ---------------- | -------- | ----------------------- | ------- | ------- |
| \_max\_per\_page | Integer  | Limit of items per page |         | 10      |
| \_page           | integer  | Page of the collection  |         | 1       |

**Headers**

| Name            | Required | Description                                                    |
| --------------- | -------- | -------------------------------------------------------------- |
| Content-Type    | true     | Format of the request                                          |
| Authorization   | true     | User token (example: Bearer \[token]                           |
| Accept-Language | false    | Language use for the response (user setting can override this) |

### Get specific information about an AB Tasty user

`GET /api/core/accounts/[account_id]/membership/[membership_id]`

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

```
https://api.abtasty.com/api/core/accounts/41902/membership/132419
```

{% endtab %}

{% tab title="Response" %}

```json
{
    "id": 132419,
    "role": "admin",
    "_links": {
        "self": {
            "href": "/api/core/accounts/41902/membership/132419"
        },
        "account": {
            "href": "/api/core/accounts/41902"
        }
    },
    "_embedded": {
        "user": {
            "id": 43571,
            "email": "arthur.charbit@abtasty.com",
            "lastname": "Charbit",
            "firstname": "Arthur",
            "creation_date": "2016-10-10T11:43:06+0200",
            "connection_count": 1161,
            "last_login_time": "2019-02-20T10:13:55+0100",
            "mfa_enabled": true,
            "_links": {
                "self": {
                    "href": "/api/core/users/43571"
                }
            },
            "_embedded": {
                "has_multiple_accounts": true
            }
        }
    }
}
```

{% endtab %}
{% endtabs %}

**Requirements**

| Name           | Requirements | Type    | Description       |
| -------------- | ------------ | ------- | ----------------- |
| account\_id    | \d+          | integer | ID of the account |
| membership\_id | \d+          | Integer | ID of the user    |

**Headers**

| Name            | Required | Description                                                    |
| --------------- | -------- | -------------------------------------------------------------- |
| Content-Type    | true     | Format of the request                                          |
| Authorization   | true     | User token (example: Bearer \[token]                           |
| Accept-Language | false    | Language use for the response (user setting can override this) |

### Give access to an AB Tasty user

`POST /api/core/accounts/[account_id]/membership`

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

```
https://api.abtasty.com/api/core/accounts/41902/membership
```

> And the body you need to insert:

```json
{
  "email":"test@gmail.com",
  "role":"user"
}
```

{% endtab %}
{% endtabs %}

> if you correctly have access to the account, it will return a 200.

**Requirements**

| Name        | Requirements | Type    | Description       |
| ----------- | ------------ | ------- | ----------------- |
| account\_id | \d+          | integer | ID of the account |

**Parameters**

| Name  | Required | Description           | Format                          |
| ----- | -------- | --------------------- | ------------------------------- |
| email | true     | Email of the new user | *email address*                 |
| role  | true     | Role of the user      | \[admin\|user\|creator\|viewer] |

**Headers**

| Name            | Required | Description                                                    |
| --------------- | -------- | -------------------------------------------------------------- |
| Content-Type    | true     | Format of the request                                          |
| Authorization   | true     | User token (example: Bearer \[token]                           |
| Accept-Language | false    | Language use for the response (user setting can override this) |

#### Change the role of an AB Tasty user

`PATCH /api/core/accounts/[account_id]/membership/[membership_id]`

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

```
https://api.abtasty.com/api/core/accounts/41902/membership/132419
```

> And the body you need to insert:

```json
{
  "role":"user"
}
```

{% endtab %}
{% endtabs %}

> if you correctly have access to the account, it will return a 204 no content.

**Requirements**

| Name           | Requirements | Type    | Description       |
| -------------- | ------------ | ------- | ----------------- |
| account\_id    | \d+          | integer | ID of the account |
| membership\_id | \d+          | Integer | ID of the user    |

**Parameters**

| Name  | Required | Description           | Format                          |
| ----- | -------- | --------------------- | ------------------------------- |
| email | true     | Email of the new user | *email address*                 |
| role  | true     | Role of the user      | \[admin\|user\|creator\|viewer] |

**Headers**

| Name            | Required | Description                                                    |
| --------------- | -------- | -------------------------------------------------------------- |
| Content-Type    | true     | Format of the request                                          |
| Authorization   | true     | User token (example: Bearer \[token]                           |
| Accept-Language | false    | Language use for the response (user setting can override this) |

### Revoke access to a user

`DELETE /api/core/accounts/[account_id]/membership/[membership_id]`

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

```
https://api.abtasty.com/api/core/accounts/41902/membership/132419
```

{% endtab %}
{% endtabs %}

> The request will return a 204 No Content if successful

**Requirements**

| Name           | Requirements | Type    | Description       |
| -------------- | ------------ | ------- | ----------------- |
| account\_id    | \d+          | integer | ID of the account |
| membership\_id | \d+          | Integer | ID of the user    |

**Headers**

| Name            | Required | Description                                                    |
| --------------- | -------- | -------------------------------------------------------------- |
| Content-Type    | true     | Format of the request                                          |
| Authorization   | true     | User token (example: Bearer \[token]                           |
| Accept-Language | false    | Language use for the response (user setting can override this) |

## Update the AB Tasty Script

With this role you will be able to:

* [Update the AB Tasty Script](#update-the-ab-tasty-script)
* [Clear the AB Tasty Script](#clear-the-ab-tasty-script)

### Update the AB Tasty Script

`PATCH /backend/accounts/[account_id]/tag-rebuild`

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

```
https://api.abtasty.com/backend/accounts/41902/tag-rebuild
```

{% endtab %}
{% endtabs %}

> The request will return a 204 No Content if successful

**Requirements**

| Name        | Requirements | Type    | Description       |
| ----------- | ------------ | ------- | ----------------- |
| account\_id | \d+          | integer | ID of the account |

**Headers**

| Name            | Required | Description                                                    |
| --------------- | -------- | -------------------------------------------------------------- |
| Content-Type    | true     | Format of the request                                          |
| Authorization   | true     | User token (example: Bearer \[token]                           |
| Accept-Language | false    | Language use for the response (user setting can override this) |

### Clear the AB Tasty Script

`PATCH /backend/accounts/[account_id]/tag-clear`

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

```
https://api.abtasty.com/backend/accounts/41902/tag-clear
```

{% endtab %}
{% endtabs %}

> The request will return a 204 No Content if successful

{% hint style="danger" %}
Be careful, every experiments and customization in your website will not be available anymore. This is useful if you notice errors on your site and suspect AB Tasty. Any update of the script will generate the script again (play, pause, update\_script,...).
{% endhint %}

**Requirements**

| Name        | Requirements | Type    | Description       |
| ----------- | ------------ | ------- | ----------------- |
| account\_id | \d+          | integer | ID of the account |

**Headers**

| Name            | Required | Description                                                    |
| --------------- | -------- | -------------------------------------------------------------- |
| Content-Type    | true     | Format of the request                                          |
| Authorization   | true     | User token (example: Bearer \[token]                           |
| Accept-Language | false    | Language use for the response (user setting can override this) |

## Get framework checksum

With this role you will be able to get the checksum generated for your tag. The route will return the last 10 generated checksums corresponding to the last 10 versions of your tag.

{% hint style="success" %}
The checksum is generated in SHA512, binary and Base64. It validates the following command:\
`openssl dgst -sha512 -binary | openssl enc -base64 -A`
{% endhint %}

### Get the framework checksum

`GET /api/v1/accounts/[account_id]`

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

```
https://api.abtasty.com/api/v1/accounts/41902
```

{% endtab %}

{% tab title="Response" %}

```json
 {
    [...]
    "checksum_files": [
        {
            "id": 2558,
            "size": 63367,
            "hash": "4c686e5eeb730235c3ae8947bf3690bc5c1a86b318eccbec4b2930f7e8eab76b",
            "created_at": {
                "readable_date": "2020-11-25T14:38:03+0100",
                "timestamp": 1606311483,
                "pattern": "Y-m-d\\TH:i:sO"
            }
        },
        {
            "id": 3570,
            "size": 63204,
            "hash": "b7ebcfd73d8aac02960add7f3c1fa12ccca435daeb2a29d6843fd91b8d6396dd",
            "created_at": {
                "readable_date": "2020-11-25T17:27:56+0100",
                "timestamp": 1606321676,
                "pattern": "Y-m-d\\TH:i:sO"
            }
        }
    ]
}
```

{% endtab %}
{% endtabs %}

**Requirements**

| Name        | Requirements | Type    | Description       |
| ----------- | ------------ | ------- | ----------------- |
| account\_id | \d+          | integer | ID of the account |

**Headers**

| Name          | Required | Description                                   |
| ------------- | -------- | --------------------------------------------- |
| Content-Type  | true     | application/json                              |
| Authorization | true     | authorization token (example: Bearer \[token] |

## Status Code

| Status code | Description                                                           |
| ----------- | --------------------------------------------------------------------- |
| \[201]      | Returned when resource is create                                      |
| \[400]      | Returned when one or more parameters are invalid                      |
| \[401]      | Returned when authentication is required                              |
| \[403]      | Returned when you have not the necessary permissions for the resource |
| \[404]      | Returned when resource could not be found                             |


---

# 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://docs.abtasty.com/client-side/data-apis/public-api.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.
