> ## Knowledge Base Index
> Fetch the complete knowledge base index at: https://support.wiraya.com/sitemap.xml
> Use this file to discover available pages before exploring further.
> Pure-Markdown content can be obtained by appending a '.md' suffix to the content URLs listed in the sitemap (without the trailing slash).

# Add contact to a Communication Flow

The flow for adding a contact to a communication flow is as follows:

1. Authenticate
2. Add the contact to our system
3. Connect contact to the correct communication flow
4. When a contact has made a conversion or opt-out, send us an event

Read more about the API here

## 1. Authentication

```
POST https://api.wiraya.ai/auth/token/apikey HTTP/1.1  
Content-Type: application/json; charset=utf-8  
{"key":"YOUR API KEY"}
```

## 2. Add contact

```
PUT https://api.wiraya.ai/api/Contact/12345 HTTP/1.1  
Authorization: Bearer [YOUR TOKEN]  
Content-Type: application/json  
{  
"schema": 1,  
"personal": {  
"phoneNumber":"46704134561",  
"givenName": "John",  
"surName": "Doe",  
"title": string,  
"gender": "Male",  
"birthDate": "1980-01-01",  
}  
"general": {  
"city": "Testershire",  
"county": "Dorset",  
"country": "UK",  
"timeOfRegistration": "2018-03-30T16:43:11Z",  
"postCode": "DT11 0PS",  
"accountStatus": "active",  
"forgotPasswdTimes": 7,  
"latestClientDetailUpdate": "2018-04-11T11:21:43Z",  
"nrLogins": 6,  
"latestLogin": "2018-05-07T19:22:11Z"  
}  
}
```

## 3. Connect contact to a campaign

```
POST https://api.wiraya.ai/api/Contact/12345/campaigns HTTP/1.1  
Authorization: Bearer [YOUR TOKEN]  
Content-Type: application/json  
{  
"campaign": "foo",  
"iteration": "2017-09"  
}
```

## 4. Send an event

```
POST https://api.wiraya.ai/api/Contact/12345/events HTTP/1.1  
Authorization: Bearer [YOUR TOKEN]  
Content-Type: application/json  
{  
"at": "2017-01-02T03:04:05Z",  
"name": "Conversion",  
"schema": 1  
}
```

This is a simplified example, more information exists in the [documentation](https://support.wiraya.com/developer/api-specification).

## Data attributes

At a minimum, we need the telephone numbers and any data attributes we use in the direct communication (for example, user name if that is to be included in the communication

However, if we receive more data we can enable the machine learning capabilities and try to predict timing, content, and channel.

Some examples of data we currently ingest:

* Unique customer ID
* Mobile telephone number
* Demographic information (Gender, Birthdate, City, Zipcode, Age)
* Registration event (datetime, referral, path to reg)
* Location (coordinates) when registering
* Conversion (When it happens, amount)
* Affiliate data
* Segment memberships (Your segments)
* 3rd-party analytic tools (A/B, Web Analytics (GA 360))
* Ad-network data (DMP)
* 1st/3rd-party cookie data