# Events

### GET /events

Retrieve a list events

| Parameter | Type  | Required | Description                                    |
| --------- | ----- | -------- | ---------------------------------------------- |
| limit     | query | No       | Items per page returned. Default: 25, Max: 100 |
| page      | query | No       | Number of the page returned. Default: 0        |

**Example**

```
curl -X GET \
  'https://api.woowup.com/apiv3/events?limit=100&page=0' \
  -H 'accept: application/json' \
  -H 'authorization: Basic XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' \
  -H 'cache-control: no-cache'
```

**Response**

```
[
    {
        "id": 1234,
        "name": "view-product",
        "createtime": "2017-05-10 14:32:12"
    },
    {
        "id": 1235,
        "name": "view-category",
        "createtime": "2017-05-10 14:32:12"
    },
    {
        "id": 1236,
        "name": "purchase-product",
        "createtime": "2017-05-10 14:32:12"
    }
]
```

**Errors**

| HttpCode | HttpCode Name  | Code            | Description                                       |
| -------- | -------------- | --------------- | ------------------------------------------------- |
| 200      | ok             | ok              | Request successful                                |
| 400      | bad request    | bad\_request    | Invalid parameters, view message for more details |
| 500      | internal error | internal\_error | Unexpected error                                  |

### POST /events

Create a new event.

| Parameter | Required | Description                                               |
| --------- | -------- | --------------------------------------------------------- |
| name      | Yes      | Event name, only accepted alphanumeric characters and "-" |

**JSON Body format**

```
{
  "name": "view-product"
}
```

**Example**

This is a curl example:

```
curl -X POST \
  https://api.woowup.com/apiv3/events \
  -H 'accept: application/json' \
  -H 'authorization: Basic xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' \
  -H 'cache-control: no-cache' \
  -d '{
  "name": "view-product"
}'
```

**Response**

This is a curl example:

```
{
  "id": 1234
  "name": "view-product",
  "createtime": "2017-07-21 13:43:29"
}
```

**Errors**

| HttpCode | HttpCode Name  | Code            | Description                                                           |
| -------- | -------------- | --------------- | --------------------------------------------------------------------- |
| 200      | ok             | ok              | Request successful                                                    |
| 400      | bad request    | bad\_request    | Invalid parameters or duplicated event, view message for more details |
| 500      | internal error | internal\_error | Unexpected error                                                      |

### POST /user-events

Associate an event to user

**JSON Body format**

```
{
  "event": "view-product",
  "service_uid": "example@email.com",
  "datetime": "2017-06-21 09:52:12",
  "metadata": {
    "campo 1": "valor 1",
    "campo 2": "valor 2",
  }
}
```

{% hint style="warning" %}
Recuerda que el "service\_uid" puede variar. Hay cuentas que utilizan el correo y otras que pueden usar el documento o un id interno. Utilizar el indicado para tu cuenta, en caso de no saber cual es consulta con el equipo de soporte.
{% endhint %}

{% hint style="danger" %}
Si se envia el campo "datetime" en el formato del ejemplo, por default interpreta que esta en UTC.  Para utilizar tu timezone, es necesario formatear la fecha bajo el standard ISO 8601.&#x20;

Ejemplo *GMT-5*: 2004-02-12T15:19:21-05:00&#x20;
{% endhint %}

**Example**

This is a curl example:

```
curl -X POST \
  https://api.woowup.com/apiv3/user-events \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -H 'authorization: Basic xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' \
  -H 'cache-control: no-cache' \
  -d '{ "event": "view-product", "service_uid": "example@email.com", "datetime": "2017-06-21 09:52:12", "metadata": { "campo 1": "valor 1" } }'
```

**Errors**

| HttpCode | HttpCode Name  | Code            | Description                                                           |
| -------- | -------------- | --------------- | --------------------------------------------------------------------- |
| 200      | ok             | ok              | Request successful                                                    |
| 400      | bad request    | bad\_request    | Invalid parameters or duplicated event, view message for more details |
| 404      | not found      | not\_found      | Event or user not found, view message for more details                |
| 500      | internal error | internal\_error | Unexpected error                                                      |

### GET /user-events

Retrieve a list of user events

| Parameter    | Type  | Required | Description                                    |
| ------------ | ----- | -------- | ---------------------------------------------- |
| limit        | query | No       | Items per page returned. Default: 25, Max: 100 |
| page         | query | No       | Number of the page returned. Default: 0        |
| service\_uid | query | No       | service\_uid of user                           |
| event        | query | No       | event name                                     |

#### Example <a href="#example-3" id="example-3"></a>

```
curl -X GET \
  'https://api.woowup.com/apiv3/user-events' \
  -H 'accept: application/json' \
  -H 'authorization: Basic XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' \
  -H 'cache-control: no-cache'
```

#### Response <a href="#response-2" id="response-2"></a>

```
{
  "payload": [
    {
      "id": 1,
      "event": {
        "id": 1,
        "name": "ingreso-club",
        "createtime": "2017-07-18 12:54:37"
      },
      "user": {
        "userapp_id": 37679,
        "user_id": 37791,
        "service_uid": "user@customer.com",
        "email": "user@customer.com"
      },
      "datetime": "2017-07-18 10:05:03",
      "metadata": null
    },
    {
      "id": 2,
      "event": {
        "id": 1,
        "name": "ingreso-club",
        "createtime": "2017-07-18 12:54:37"
      },
      "user": {
        "userapp_id": 37679,
        "user_id": 37791,
        "service_uid": "user@customer.com",
        "email": "user@customer.com"
      },
      "datetime": "2017-07-18 10:05:38",
      "metadata": null
    }
  ],
  "message": "ok",
  "code": "ok",
  "time": "1159ms"
}
```

**Errors**

| HttpCode | HttpCode Name  | Code            | Description                                                           |
| -------- | -------------- | --------------- | --------------------------------------------------------------------- |
| 200      | ok             | ok              | Request successful                                                    |
| 400      | bad request    | bad\_request    | Invalid parameters or duplicated event, view message for more details |
| 500      | internal error | internal\_error | Unexpected error                                                      |

## Delete event

<mark style="color:red;">`DELETE`</mark> `https://api.woowup.com/apiv3/events/{id}`

Delete an event

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

```javascript
{
    "payload": [],
    "message": "",
    "code": "ok",
    "time": "52ms"
}
```

{% endtab %}

{% tab title="404 " %}

```javascript
{
    "payload": [],
    "message": "event not found",
    "code": "not_found",
    "time": "39ms"
}
```

{% endtab %}

{% tab title="500 " %}

```javascript
{
    "payload": [],
    "message": "",
    "code": "internal_error",
    "time": "72ms"
}
```

{% endtab %}
{% endtabs %}

**Example**

```bash
curl -X DELETE \
  https://api.woowup.com/apiv3/events/999999 \
  -H 'Accept: application/json' \
  -H 'Authorization: Basic XXXXXXXXXXXXXXXXXXXX' \
  -H 'Content-Type: application/json' \

```

**Response**

```javascript
{
    "payload": [],
    "message": "",
    "code": "ok",
    "time": "52ms"
}
```

## Delete user events (bulk)

<mark style="color:red;">`DELETE`</mark> `https://api.woowup.com/apiv3/user-events/bulk`

#### Request Body

| Name        | Type   | Description                       |
| ----------- | ------ | --------------------------------- |
| event\_name | string |                                   |
| from        | string | date format YYYY-MM-DD hh:mm:ss   |
| to          | string | date format YYYY-MM-DD hh:mm:ss   |
| notify\_to  | string | email to receive the confirmation |

{% tabs %}
{% tab title="200 will be receive an email when the deletion process is finished" %}

```javascript
{
    "payload": {
        "request_id": "XXX"
    },
    "message": "ok",
    "code": "ok",
    "time": "111ms"
}
```

{% endtab %}

{% tab title="400 " %}

```javascript
//bad_request
{
    "payload": {
        "errors": [
            "Failed matching any of the provided schemas."
        ]
    },
    "message": "bad request",
    "code": "bad_request",
    "time": "38ms"
}

//invalid_email
{
    "payload": [],
    "message": "Invalid email to notify",
    "code": "invalid_email",
    "time": "48ms"
}
```

{% endtab %}

{% tab title="403 " %}

```javascript
{
    "payload": [],
    "message": "forbidden: authentication failed",
    "code": "forbidden",
    "time": "7ms"
}
```

{% endtab %}

{% tab title="404 " %}

```javascript
{
    "payload": {
        "errors": [
            "event not found"
        ]
    },
    "message": "event not found",
    "code": "not_found",
    "time": "51ms"
}
```

{% endtab %}

{% tab title="500 " %}

```javascript
{
    "payload": [],
    "message": "",
    "code": "internal_error",
    "time": "72ms"
}
```

{% endtab %}
{% endtabs %}

**Example**

```bash
curl -X DELETE \
  https://api.woowup.com/apiv3/user-events/bulk \
  -H 'Accept: application/json' \
  -H 'Authorization: Basic XXXXXXXXXXXXXXXXXXXX' \
  -H 'Content-Type: application/json' \
  -d '{
    "event-name": "eventExample"
	"from": "2019-07-01",
	"to": "2019-07-31",
    "notify_to": "test@email.com"
}'
```

**Response**

```javascript
{
    "payload": {
        "request_id": "XXX"
    },
    "message": "ok",
    "code": "ok",
    "time": "111ms"
}
```


---

# 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://woowup-docs.gitbook.io/woowup-developer-docs/api/events.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.
