# Pixels

"Pixel" refers to retargeting pixel script that can be inserted in the html to track users clicking shortened link. You can *create*, *access*, *update* and *delete* Pixel.

* [Create](#create-pixel)
* [Update](#update-pixel)
* [Delete](#delete)
* [Access](#access)
* [Access all pixels](#alllinks)

## Create pixel

*POST* <https://to.click/api/v1/pixels>

*HEADERS*

```
X-AUTH-TOKEN: jvuhNJgV59Wo6HRmtVxEgDEU
Content-Type: application/json
```

*BODY*

```
{ "data": { "type": "pixel", "attributes": { "name": "Test pixel", "pixel_text": "<javascript>...</javascript>" } }}
```

### Sample Request

```
curl --request POST  --url 
https://to.click/api/v1/pixels
  --header 'Content-Type: application/json'  --header 'X-AUTH-TOKEN: jvuhNJgV59Wo6HRmtVxEgDEU'  
  --data '{ "data": { "type": "pixel", "attributes": { "name": "Test pixel", "pixel_text": "<javascript>...</javascript>" } }}'
```

| JSON element | Description  | Type   | Required? |
| ------------ | ------------ | ------ | --------- |
| name         | Pixel Name   | String | Yes       |
| pixel\_text  | Pixel script | String | Yes       |

### Sample response

```
{
    "data": {
        "id": "12",
        "type": "pixel",
        "attributes": {
            "name": "Test pixel",
            "pixel_text": "<javascript>...</javascript>",
            "created_at": "2018-03-01T15:34:46.362+03:00"
        }
    }
}
```

## Update pixel

*PUT* <https://to.click/api/v1/pixels/7>

*HEADERS*

```
X-AUTH-TOKEN: jvuhNJgV59Wo6HRmtVxEgDEU
Content-Type: application/json
```

*BODY*

```
{ "data": { "type": "pixel7", "attributes": { "name": "Test pixel", "pixel_text": "<javascript>...</javascript>" } }}
```

### Sample Request

```
curl --request PUT  --url 
https://to.click/api/v1/pixels/7
  --header 'Content-Type: application/json'  --header 'X-AUTH-TOKEN: jvuhNJgV59Wo6HRmtVxEgDEU'  --data '{ "data": { "type": "pixel7", "attributes": { "name": "Test pixel", "pixel_text": "<javascript>...</javascript>" } }}'
```

## Delete pixel

*DELETE* <https://click.to/api/v1/pixels/7>

*HEADERS*

```
X-AUTH-TOKEN: jvuhNJgV59Wo6HRmtVxEgDEU
Content-Type: application/json
```

### Sample Request

```
curl --request DELETE  --url 
https://click.to/api/v1/pixels/7
  --header 'Content-Type: application/json'  --header 'X-AUTH-TOKEN: jvuhNJgV59Wo6HRmtVxEgDEU'
```

## Get all pixels

*GET* <https://to.click/api/v1/pixels>

*HEADERS*

```
X-AUTH-TOKEN: jvuhNJgV59Wo6HRmtVxEgDEU
Content-Type: application/json
```

### Sample Request

```
curl --request GET  --url 
https://to.click/api/v1/pixels
  --header 'Content-Type: application/json'  --header 'X-AUTH-TOKEN: jvuhNJgV59Wo6HRmtVxEgDEU'
```

### Sample Response

```
{
    "data": [
        {
            "id": "12",
            "type": "pixel",
            "attributes": {
                "name": "Test pixel",
                "pixel_text": "<javascript>alert('!!!')</javascript>",
                "created_at": "2018-03-01T15:34:46.362+03:00"
            }
        },
        {
            "id": "13",
            "type": "pixel",
            "attributes": {
                "name": "Test pixel 2",
                "pixel_text": "<javascript>...</javascript>",
                "created_at": "2018-03-01T15:43:10.894+03:00"
            }
        }
    ]
}
```

## Get pixel

*GET* <https://to.click/api/v1/pixels/1>

*HEADERS*

```
X-AUTH-TOKEN: jvuhNJgV59Wo6HRmtVxEgDEU
Content-Type: application/json
```

### Sample Request

```
curl --request GET  --url 
https://to.click/api/v1/pixels/12
  --header 'Content-Type: application/json'  --header 'X-AUTH-TOKEN: jvuhNJgV59Wo6HRmtVxEgDEU'
```

### Sample Response

```
{
    "data": {
        "id": "12",
        "type": "pixel",
        "attributes": {
            "name": "Test pixel",
            "pixel_text": "<javascript>...</javascript>",
            "created_at": "2018-03-01T15:34:46.362+03:00"
        }
    }
}
```
