﻿<a id="invitation_created"></a>

# Invitation created

## Overview

!!! note
    - INVITER - the person who has invited someone from his contacts
    - INVITEE - the person who has been invited

When "contact sync" and "smart contacts" features are enabled for Cloud Softphone apps, users can invite people from
their address books to join the same network.

Invitations are collected by Acrobits Contacts server. Optionally, the server can notify provider whenever someone is
invited via a web service described in this document. Implementation of this web service is not required, invitations
will work fine without it. It gives providers a way to keep track of the invitations process.

## Parameters

The parameters for this web service are fixed: `invitee`, `invitor`, `network_id`. No other parameter keywords are
recognized.

### `invitee` { .reference-entry }

The phone number of the invited user who was just invited.

### `invitor` { .reference-entry }

SIP username of the user who invited `invitee`.

### `network_id` { .reference-entry }

This will be typically Cloud ID of the Cloud Softphone application. In case provider sends `network_id` in the
response of [External Authentication](../provisioning/ext_auth.md) web service, it will be used here as well.

## Configuration

The web service is configured via Cloud Softphone web portal "Provisioning Options" (Step 2).

### `invitationCreatedUrl` { .reference-entry }

Contains the URL, including URL scheme, of the web service. If you wish to use GET method, specify the query string
here as well.

Example (with query-string):

```
https://example.com/invitation/?invitee=%invitee%&invitor=%invitor%&net=%network_id%
```

### `invitationCreatedPostData` { .reference-entry }

If filled in, Contacts server will use HTTP POST method to report the new invitation.

Example (for application/json):

```json
{ "invitee" : "%invitee%", "invitor" : "%invitor%", "network" : "%network_id%" }
```

### `invitationCreatedContentType` { .reference-entry }

Specifies the value of Content-Type header to be sent in the request. If not specified, the app will default
to application/x-www-form-urlencoded. Supported content types are:

- application/json
- application/x-www-form-urlencoded
- application/xml

## Response

The response will be considered successful if the HTTP response code is 204. Any responses which have other
response code are silently ignored.

See the examples below for the recognized formats of the responses. Because both webservices have same format here
is example of just second webservice.

## Examples

### GET method

request:

```http
GET /invitation_created/?invitee=15551231234&invitor=johnsnow&network_id=mynetwork HTTP/1.1
Host: example.com
Connection: close
Cache-Control: max-age=0
User-Agent: Sync Server 1.0
```

response:

```http
HTTP/1.1 204 No Content
Date: Sun, 15 Mar 2015 00:46:17 GMT
Server: Apache/2.4.7 (Ubuntu)
Vary: Accept-Encoding
Content-Length: 123
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
```

### POST method, XML

request:

```http
POST /invitation_created/ HTTP/1.1
Host: example.com
Connection: close
Cache-Control: max-age=0
User-Agent: Sync Server 1.1
Content-Type: application/xml
Content-Length: 66

<root>
    <invitee>15551231234</invitee>
    <invitor>johnsnow</invitor>
    <network_id>mynetwork</network_id>
</root>
```

response:

```http
HTTP/1.1 204 No Content
Date: Sun, 15 Mar 2015 00:46:17 GMT
Server: Apache/2.4.7 (Ubuntu)
Vary: Accept-Encoding
Content-Length: 123
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
```

### POST method, JSON

request:

```http
POST /invitation_created/ HTTP/1.1
Host: example.com
Connection: close
Cache-Control: max-age=0
User-Agent: CloudSoftphone/1.5.6
Content-Type: application/json
Content-Length: 66

{"invitee" : "15551231234", "invitor" : "johnsnow", "network_id" : "mynetwork"}
```

response:

```http
HTTP/1.1 204 No Content
Date: Sun, 15 Mar 2015 00:46:17 GMT
Server: Apache/2.4.7 (Ubuntu)
Vary: Accept-Encoding
Content-Length: 123
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
```

