Groups

This API mainly allows you to add, update, delete and list contacts but also you can unsubscribe and resubscribe contact or list segments.

List contacts in group

get

Use this method to list all contacts in a group.

Authorizations
Path parameters
groupIdstringRequired

The group id that should be searched

Query parameters
offsetintegerOptional

The number of items omitted from the beginning of the list. Default ‘0’.

Default: 0
limitinteger · max: 1000Optional

The maximum number of items returned by request. Default ‘100’. Maximum ‘1000’.

Default: 100
orderBystringOptional

Allows you to select the field by which the sort should be performed. ( For this method: id, createdAt )

Default: id
orderDirectionstringOptional

It allows you to set the sort order for a given field. ( ASC or DESC )

Default: DESC
Responses
200
Request was successfully processed
application/json
get
using System.Threading.Tasks;

internal class Program
{
    private static void Main(string[] args)
    {
        string requestBody = "";

        try {
            using var client = new HttpClient{};
            using var request = new HttpRequestMessage(HttpMethod.Get, "https://api.messageflow.com/v2.1/group/{groupId}/contact?offset=0&limit=100&orderBy=id&orderDirection=DESC");

            request.Headers.Add("Authorization", "YourAuthorizationKey");
            request.Headers.Add("Application-Key", "YourApplicationKey");
            request.Content = new StringContent(requestBody, null, "application/json");

            var response = await client.SendAsync(request);
            response.EnsureSuccessStatusCode();
            string content = await response.Content.ReadAsStringAsync();
            Console.WriteLine(content);

        } catch (HttpRequestException e) {
            Console.WriteLine("\n Exception Caught!\n Message :{0} ", e.Message);
        }
    }
}
{
  "meta": {
    "numberOfErrors": 0,
    "numberOfData": 1,
    "status": 200,
    "uniqId": "00d928f759"
  },
  "data": [
    {
      "email": "[email protected]",
      "externalId": "XXXX-XXXXX-XXXX",
      "id": "123",
      "phoneNumber": "0123123123"
    }
  ]
}

Add contacts to group

post

Use this method to add contacts to a group.

Authorizations
Path parameters
groupIdintRequired

The id of the group.

Body

The id of a object

idinteger[]Required

The id of a object

Example: 1
Responses
200
Request was successfully processed
application/json
post
using System.Threading.Tasks;

internal class Program
{
    private static void Main(string[] args)
    {
        string requestBody = "{\"id\":[1]}";

        try {
            using var client = new HttpClient{};
            using var request = new HttpRequestMessage(HttpMethod.Post, "https://api.messageflow.com/v2.1/group/{groupId}/contact");

            request.Headers.Add("Authorization", "YourAuthorizationKey");
            request.Headers.Add("Application-Key", "YourApplicationKey");
            request.Content = new StringContent(requestBody, null, "application/json");

            var response = await client.SendAsync(request);
            response.EnsureSuccessStatusCode();
            string content = await response.Content.ReadAsStringAsync();
            Console.WriteLine(content);

        } catch (HttpRequestException e) {
            Console.WriteLine("\n Exception Caught!\n Message :{0} ", e.Message);
        }
    }
}
{
  "meta": {
    "numberOfErrors": 0,
    "numberOfData": 1,
    "status": 200,
    "uniqId": "00d928f759"
  }
}

Delete contacts from group

delete

Use this method to delete contacts from a group.

Authorizations
Path parameters
groupIdintRequired

The id of the group.

Body

The id of a object

idinteger[]Required

The id of a object

Example: 1
Responses
200
Request was successfully processed
application/json
delete
using System.Threading.Tasks;

internal class Program
{
    private static void Main(string[] args)
    {
        string requestBody = "{\"id\":[1]}";

        try {
            using var client = new HttpClient{};
            using var request = new HttpRequestMessage(HttpMethod.Delete, "https://api.messageflow.com/v2.1/group/{groupId}/contact");

            request.Headers.Add("Authorization", "YourAuthorizationKey");
            request.Headers.Add("Application-Key", "YourApplicationKey");
            request.Content = new StringContent(requestBody, null, "application/json");

            var response = await client.SendAsync(request);
            response.EnsureSuccessStatusCode();
            string content = await response.Content.ReadAsStringAsync();
            Console.WriteLine(content);

        } catch (HttpRequestException e) {
            Console.WriteLine("\n Exception Caught!\n Message :{0} ", e.Message);
        }
    }
}
{
  "meta": {
    "numberOfErrors": 0,
    "numberOfData": 1,
    "status": 200,
    "uniqId": "00d928f759"
  }
}

List groups

get

Use this method to list all groups.

Authorizations
Query parameters
offsetintegerOptional

The number of items omitted from the beginning of the list. Default ‘0’.

Default: 0
limitinteger · max: 1000Optional

The maximum number of items returned by request. Default ‘100’. Maximum ‘1000’.

Default: 100
orderBystringOptional

Specifies a required order for the query results. You can order only by id, createdAt and name.

Default: id
orderDirectionstringOptional

Specifies the sort order. To sort the groups in descending order, use DESC to sort in ascending order, use ASC.

Default: DESC
Responses
200
Request was successfully processed
application/json
get
using System.Threading.Tasks;

internal class Program
{
    private static void Main(string[] args)
    {
        string requestBody = "";

        try {
            using var client = new HttpClient{};
            using var request = new HttpRequestMessage(HttpMethod.Get, "https://api.messageflow.com/v2.1/group?offset=0&limit=100&orderBy=id&orderDirection=DESC");

            request.Headers.Add("Authorization", "YourAuthorizationKey");
            request.Headers.Add("Application-Key", "YourApplicationKey");
            request.Content = new StringContent(requestBody, null, "application/json");

            var response = await client.SendAsync(request);
            response.EnsureSuccessStatusCode();
            string content = await response.Content.ReadAsStringAsync();
            Console.WriteLine(content);

        } catch (HttpRequestException e) {
            Console.WriteLine("\n Exception Caught!\n Message :{0} ", e.Message);
        }
    }
}
{
  "meta": {
    "numberOfErrors": 0,
    "numberOfData": 1,
    "status": 200,
    "uniqId": "00d928f759"
  },
  "data": [
    {
      "createdAt": 1,
      "id": 1234,
      "name": "test",
      "description": "Test descr"
    }
  ]
}

Create group

post

Use this method to create a group that you can use to send email and sms campaigns.

Authorizations
Body

Group object

namestringRequired

The group name.

Example: test
descriptionstringOptional

The group description.

Example: Test descr
externalIdstringOptional

The unique identifier of the group

Example: XXXXX-XXXX-XXXX
Responses
200
Request was successfully processed
application/json
post
using System.Threading.Tasks;

internal class Program
{
    private static void Main(string[] args)
    {
        string requestBody = "[{\"name\":\"test\",\"description\":\"Test descr\",\"externalId\":\"XXXXX-XXXX-XXXX\"}]";

        try {
            using var client = new HttpClient{};
            using var request = new HttpRequestMessage(HttpMethod.Post, "https://api.messageflow.com/v2.1/group");

            request.Headers.Add("Authorization", "YourAuthorizationKey");
            request.Headers.Add("Application-Key", "YourApplicationKey");
            request.Content = new StringContent(requestBody, null, "application/json");

            var response = await client.SendAsync(request);
            response.EnsureSuccessStatusCode();
            string content = await response.Content.ReadAsStringAsync();
            Console.WriteLine(content);

        } catch (HttpRequestException e) {
            Console.WriteLine("\n Exception Caught!\n Message :{0} ", e.Message);
        }
    }
}
{
  "meta": {
    "numberOfErrors": 0,
    "numberOfData": 1,
    "status": 200,
    "uniqId": "00d928f759"
  }
}

Update group

put

Use this method to update a group.

Authorizations
Body

Group object

idintegerOptional

The id of the group.

Example: 1234
namestringOptional

The unique name of the group.

Example: test
descriptionstringOptional

The group description.

Example: Test descr
Responses
200
Request was successfully processed
application/json
put
using System.Threading.Tasks;

internal class Program
{
    private static void Main(string[] args)
    {
        string requestBody = "[{\"id\":1234,\"name\":\"test\",\"description\":\"Test descr\"}]";

        try {
            using var client = new HttpClient{};
            using var request = new HttpRequestMessage(HttpMethod.Put, "https://api.messageflow.com/v2.1/group");

            request.Headers.Add("Authorization", "YourAuthorizationKey");
            request.Headers.Add("Application-Key", "YourApplicationKey");
            request.Content = new StringContent(requestBody, null, "application/json");

            var response = await client.SendAsync(request);
            response.EnsureSuccessStatusCode();
            string content = await response.Content.ReadAsStringAsync();
            Console.WriteLine(content);

        } catch (HttpRequestException e) {
            Console.WriteLine("\n Exception Caught!\n Message :{0} ", e.Message);
        }
    }
}
{
  "meta": {
    "numberOfErrors": 0,
    "numberOfData": 1,
    "status": 200,
    "uniqId": "00d928f759"
  }
}

Delete group

delete

Use this method to delete an existing group.

Authorizations
Body

The id of a object

idinteger[]Required

The id of a object

Example: 1
Responses
200
Request was successfully processed
application/json
delete
using System.Threading.Tasks;

internal class Program
{
    private static void Main(string[] args)
    {
        string requestBody = "{\"id\":[1]}";

        try {
            using var client = new HttpClient{};
            using var request = new HttpRequestMessage(HttpMethod.Delete, "https://api.messageflow.com/v2.1/group");

            request.Headers.Add("Authorization", "YourAuthorizationKey");
            request.Headers.Add("Application-Key", "YourApplicationKey");
            request.Content = new StringContent(requestBody, null, "application/json");

            var response = await client.SendAsync(request);
            response.EnsureSuccessStatusCode();
            string content = await response.Content.ReadAsStringAsync();
            Console.WriteLine(content);

        } catch (HttpRequestException e) {
            Console.WriteLine("\n Exception Caught!\n Message :{0} ", e.Message);
        }
    }
}
{
  "meta": {
    "numberOfErrors": 0,
    "numberOfData": 1,
    "status": 200,
    "uniqId": "00d928f759"
  }
}

Count number of contacts in group

get

Use this method to count number of contacts in group (either dynamic or static). When using this method for getting dynamic group count you may get response with Retry-After header. Please check chapter 'Long running actions - Retry-After header explained'.

Authorizations
Path parameters
groupIdintRequired

The id of the group.

Responses
200
Request was successfully processed
application/json
get
using System.Threading.Tasks;

internal class Program
{
    private static void Main(string[] args)
    {
        string requestBody = "";

        try {
            using var client = new HttpClient{};
            using var request = new HttpRequestMessage(HttpMethod.Get, "https://api.messageflow.com/v2.1/group/{groupId}/count");

            request.Headers.Add("Authorization", "YourAuthorizationKey");
            request.Headers.Add("Application-Key", "YourApplicationKey");
            request.Content = new StringContent(requestBody, null, "application/json");

            var response = await client.SendAsync(request);
            response.EnsureSuccessStatusCode();
            string content = await response.Content.ReadAsStringAsync();
            Console.WriteLine(content);

        } catch (HttpRequestException e) {
            Console.WriteLine("\n Exception Caught!\n Message :{0} ", e.Message);
        }
    }
}
{
  "meta": {
    "numberOfErrors": 0,
    "numberOfData": 1,
    "status": 200,
    "uniqId": "00d928f759"
  }
}