# User centric API

## registerUser

`POST` `https://api.pushwoosh.com/json/1.3/registerUser`

Associates external User ID with a specified device.

#### Request headers

| Name          | Required | Value         | Description                                                |
|---------------|----------|---------------|------------------------------------------------------------|
| Authorization | Yes      | Token `XXXX`  | [API Device Token](/developer/api-reference/api-access-token/#device-api-token) to access Device API. Replace `XXXX` with your actual Device API token. |

#### Request body

| Name        | Required | Type    | Description                                                                                                  |
| ----------- | -------- | ------- | ------------------------------------------------------------------------------------------------------------ |
| userId      | No       | string  | [User ID](/developer/api-reference/api-identifiers/#user-id) to associate with a device. If empty, use hwid. |
| application | Yes      | string  | [Pushwoosh application code](/developer/api-reference/api-identifiers/#application-code)                    |
| hwid        | Yes      | string  | [Pushwoosh HWID](/developer/api-reference/api-identifiers/#hardware-id)                                     |
| tz\_offset  | No       | integer | Timezone offset in seconds for the device.                                                                   |
| device\_type| No       | integer | [Device type](/developer/api-reference/api-identifiers/#device-type). See possible values in `/registerDevice`. |

Can be used later in [`/createMessage`](/developer/api-reference/messages-api/#createmessage) API call (the _users_ parameter).\
You can call this function before you have the push token and before the [`/registerDevice`](/developer/api-reference/device-api/#registerdevice) call.

#### Request example

```json
{
  "request": {
    "userId": "user_3078a",                     // optional. If empty, use hwid
    "application": "XXXXX-XXXXX",               // required. Pushwoosh application code
    "hwid": "8f65b16df378e7a6bece9614e1530fb2", // required. Hardware device ID
    "tz_offset": -3600,                         // optional. Timezone offset in seconds
    "device_type": 3                            // optional. Device type, see /registerDevice
                                                //           for device types
  }
}
```

#### Response example

<Tabs>
<TabItem label="200">
```json
{
  "status_code": 200, 
  "status_message": "OK",
  "response": null
}
```
</TabItem>
</Tabs>

<Aside type="note">
For emails, call [`/registerEmailUser`](/developer/api-reference/email-api/#registeremailuser).
</Aside>

## deleteUser

`POST` `https://api.pushwoosh.com/api/v2/device-api/deleteUser`

Deletes a user and all devices associated with the specified [User ID](/developer/api-reference/api-identifiers/#user-id) within the application. The request is processed asynchronously, and the endpoint returns `200 OK` as soon as the delete request has been accepted for processing.

#### Request headers

| Name          | Required | Value            | Description                                                |
|---------------|----------|------------------|------------------------------------------------------------|
| Authorization | Yes      | Token `XXXX`     | [API Device Token](/developer/api-reference/api-access-token/#device-api-token) to access Device API. Replace `XXXX` with your actual Device API token. |
| Content-Type  | Yes      | application/json |                                                            |

#### Request body

| Name        | Required | Type   | Description                                                                                                     |
| ----------- | -------- | ------ | --------------------------------------------------------------------------------------------------------------- |
| application | Yes      | string | [Pushwoosh application code](/developer/api-reference/api-identifiers/#application-code)                       |
| user\_id    | Yes      | string | [User ID](/developer/api-reference/api-identifiers/#user-id) to delete. All devices associated with this user in the specified application will be removed. |


#### Request example

```json
{
  "application": "XXXXX-XXXXX",   // required. Pushwoosh application code
  "user_id": "user_3078a"         // required. User ID to delete
}
```

#### Response example

<Tabs>
<TabItem label="200">
```json
{
  "status_code": 200,
  "status_message": "OK",
  "response": null
}
```
</TabItem>
</Tabs>

##### Status codes

| HTTP Status code | status\_code | Description                                        |
| ---------------- | ------------ | -------------------------------------------------- |
| 200              | 200          | Delete request accepted                            |
| 200              | 210          | Argument error. See status\_message for more info. |
| 400              | N/A          | Malformed request string                           |
| 401              | N/A          | Missing or invalid Authorization token             |
| 500              | 500          | Internal error                                     |

## postEvent

`POST` `https://api.pushwoosh.com/json/1.3/postEvent`

Triggers an event.

#### Request headers

| Name          | Required | Value         | Description                                                |
|---------------|----------|---------------|------------------------------------------------------------|
| Authorization | Yes      | Token `XXXX`  | [API Device Token](/developer/api-reference/api-access-token/#device-api-token) to access Device API. Replace `XXXX` with your actual Device API token. |


#### Request body

| Name             | Required | Type    | Description                                                                                                                                                      |
| ---------------- | -------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| hwid             | Yes      | string  | [Hardware device ID](/developer/api-reference/api-identifiers/#hardware-id) used in a /registerDevice request. Can be used along with 'userId' to identify a user who has triggered an event. |
| application      | Yes      | string  | [Pushwoosh application code](/developer/api-reference/api-identifiers/#application-code)                                                                        |
| event            | Yes      | string  | [Event name](/developer/api-reference/api-identifiers/#event-name) exactly as created in Pushwoosh Control Panel.                                              |
| attributes       | Yes      | object  | JSON object with the event attributes. Leave it empty if no attributes need to be passed.                                                                       |
| timestampUTC     | No       | integer | Timestamp in UTC.                                                                                                                                                |
| timestampCurrent | No       | integer | Timestamp in local time.                                                                                                                                         |
| userId           | Yes      | string  | [User ID](/developer/api-reference/api-identifiers/#user-id) associated with a user who has triggered the event. Can be replaced by or used along with an HWID. |
| device\_type     | No       | integer | [See possible values](/developer/api-reference/api-identifiers/#device-type)                                                                                    |

The event's name in the request must match the event name in Pushwoosh Control Panel. Note that "attributes" property may be empty (but not omitted) in case the event has no attributes.

#### Request example

```json
{
  "request":{ 
    "hwid": "8f65b16df378e7a6bece9614e1530fb2", // required. Hardware device ID used in a /registerDevice API.
                                                //           Can be used along with an userId to identify a 
                                                //           user who has triggered an event.
    "application": "XXXXX-XXXXX",               // required. Pushwoosh application code
    "event": "activityCompleted",               // required. Event name exactly as created in Pushwoosh Control Panel
    "attributes": {                             // required. Leave empty if no attributes need to be passed. 
      "login": "facebook",
      "success": "yes",
      "internet": "wifi"
    },
    "timestampUTC": 1435228403,                 // optional. Timestamp in UTC
    "timestampCurrent": 1435253603,             // optional. Timestamp in local time
    "userId": "someuser@user.com",              // required. A user id which is used for identification of 
                                                //           users on multiple devices. Can be replaced by
                                                //           or used along with an HWID.
    "device_type": 1                            // optional.
  }
}

```

#### Response example

<Tabs>
<TabItem label="200">
```json
{
  "status_code": 200,
  "status_message": "OK",
  "response": {
    "code": "61BC9-84DD0"
  }
}
```
</TabItem>
</Tabs>

#### Sending conversion events

To report revenue directly instead of [mapping an existing event](/product/audience-data-and-segmentation/events/conversion-events/), send `postEvent` with `PW_Conversion` as the event name and the transaction's `value` and `currency` in `attributes`:

```json
{
  "request":{
    "hwid": "8f65b16df378e7a6bece9614e1530fb2",
    "application": "XXXXX-XXXXX",
    "event": "PW_Conversion",
    "attributes": {
      "value": 49.99,               // required. Transaction amount
      "currency": "USD",            // required. ISO 4217 currency code
      "transaction_id": "txn_8f21", // optional. Your own transaction reference
      "product_id": "prod_premium"  // optional
    },
    "userId": "someuser@user.com"
  }
}
```

<Aside type="note">
`transaction_id` is not used by Pushwoosh to deduplicate revenue — it's stored as-is for your own reporting and reconciliation. If you report the same transaction more than once, each call is recorded separately. See [Conversion events](/product/audience-data-and-segmentation/events/conversion-events/) for how canonical events and event mapping fit together.
</Aside>