unsent
unsent.dev
API Reference

Contact Books

Organize contacts into groups, track statistics, and manage your contact lists with the Contact Books API.

Overview

Contact Books allow you to organize your contacts into logical groups (e.g., newsletters, VIP customers, product updates). Each contact book can have custom properties, emojis for easy identification, and detailed statistics about your contacts.

Base URL

https://api.unsent.dev/v1/contactBooks

Features

Organization

Group contacts into logical lists with custom names and emojis

Custom Properties

Store custom key-value metadata for each contact book

Statistics

Track total contacts, unsubscribed contacts, and associated campaigns

Contact Count

View subscriber counts for each contact book

Endpoints

List Contact Books

Retrieve all contact books for your team. Returns basic information including contact counts.

Endpoint: GET /v1/contactBooks

Response Schema

FieldTypeDescription
idstringUnique identifier for the contact book
namestringName of the contact book
emojistringEmoji icon for the contact book
teamIdstringID of the team that owns this contact book
propertiesobjectCustom key-value properties
createdAtstringISO 8601 timestamp when created
updatedAtstringISO 8601 timestamp when last updated
_count.contactsnumberTotal number of contacts in this book

Response Example

[
  {
    "id": "clxy123abc",
    "name": "Newsletter Subscribers",
    "emoji": "๐Ÿ“ฐ",
    "teamId": "team_abc123",
    "properties": {
      "source": "website",
      "segment": "engaged"
    },
    "createdAt": "2024-01-15T10:30:00.000Z",
    "updatedAt": "2024-01-20T14:45:00.000Z",
    "_count": {
      "contacts": 1523
    }
  },
  {
    "id": "clxy456def",
    "name": "VIP Customers",
    "emoji": "โญ",
    "teamId": "team_abc123",
    "properties": {},
    "createdAt": "2024-01-10T08:00:00.000Z",
    "updatedAt": "2024-01-18T16:20:00.000Z",
    "_count": {
      "contacts": 87
    }
  }
]

cURL Example

curl -X GET "https://api.unsent.dev/v1/contactBooks" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json"

Create Contact Book

Create a new contact book to start organizing your contacts.

Endpoint: POST /v1/contactBooks

Request Body

FieldTypeRequiredDescription
namestringYesName of the contact book (minimum 1 character)
emojistringNoEmoji icon for visual identification
propertiesobjectNoCustom key-value metadata (string to string mapping)

[!NOTE] Currently, the API only uses the name field when creating contact books. The emoji and properties fields are accepted in the request but may not be persisted depending on the service implementation.

Response Schema

FieldTypeDescription
idstringUnique identifier for the created contact book
namestringName of the contact book
emojistringEmoji icon
teamIdstringID of the team that owns this contact book
propertiesobjectCustom key-value properties
createdAtstringISO 8601 timestamp when created
updatedAtstringISO 8601 timestamp when last updated

Request Example

{
  "name": "Product Updates",
  "emoji": "๐Ÿš€",
  "properties": {
    "category": "product",
    "frequency": "weekly"
  }
}

Response Example

{
  "id": "clxy789ghi",
  "name": "Product Updates",
  "emoji": "๐Ÿš€",
  "teamId": "team_abc123",
  "properties": {
    "category": "product",
    "frequency": "weekly"
  },
  "createdAt": "2024-01-25T09:15:00.000Z",
  "updatedAt": "2024-01-25T09:15:00.000Z"
}

cURL Example

curl -X POST "https://api.unsent.dev/v1/contactBooks" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Product Updates",
    "emoji": "๐Ÿš€",
    "properties": {
      "category": "product",
      "frequency": "weekly"
    }
  }'

Get Contact Book

Retrieve detailed information about a specific contact book, including statistics about contacts and associated campaigns.

Endpoint: GET /v1/contactBooks/{id}

Path Parameters

ParameterTypeDescription
idstringUnique identifier of the contact book

Response Schema

FieldTypeDescription
idstringUnique identifier for the contact book
namestringName of the contact book
emojistringEmoji icon
teamIdstringID of the team that owns this contact book
propertiesobjectCustom key-value properties
createdAtstringISO 8601 timestamp when created
updatedAtstringISO 8601 timestamp when last updated
details.totalContactsnumberTotal number of contacts in this book
details.unsubscribedContactsnumberNumber of unsubscribed contacts
details.campaignsarrayList of campaigns associated with this contact book

Response Example

{
  "id": "clxy123abc",
  "name": "Newsletter Subscribers",
  "emoji": "๐Ÿ“ฐ",
  "teamId": "team_abc123",
  "properties": {
    "source": "website",
    "segment": "engaged"
  },
  "createdAt": "2024-01-15T10:30:00.000Z",
  "updatedAt": "2024-01-20T14:45:00.000Z",
  "details": {
    "totalContacts": 1523,
    "unsubscribedContacts": 47,
    "campaigns": [
      {
        "id": "camp_xyz123",
        "name": "Weekly Newsletter",
        "createdAt": "2024-01-16T12:00:00.000Z"
      }
    ]
  }
}

cURL Example

curl -X GET "https://api.unsent.dev/v1/contactBooks/clxy123abc" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json"

Error Responses

  • 404 Not Found: Contact book not found or doesn't belong to your team
{
  "code": "NOT_FOUND",
  "message": "Contact book not found"
}

Update Contact Book

Update the name, emoji, or custom properties of an existing contact book.

Endpoint: PATCH /v1/contactBooks/{id}

Path Parameters

ParameterTypeDescription
idstringUnique identifier of the contact book to update

Request Body

All fields are optional. Only include the fields you want to update.

FieldTypeRequiredDescription
namestringNoNew name for the contact book
emojistringNoNew emoji icon
propertiesobjectNoUpdated custom key-value metadata

Response Schema

FieldTypeDescription
idstringUnique identifier of the updated contact book
namestringCurrent name of the contact book

Request Example

{
  "name": "Premium Newsletter Subscribers",
  "emoji": "๐Ÿ’Ž",
  "properties": {
    "source": "website",
    "segment": "premium"
  }
}

Response Example

{
  "id": "clxy123abc",
  "name": "Premium Newsletter Subscribers"
}

cURL Example

curl -X PATCH "https://api.unsent.dev/v1/contactBooks/clxy123abc" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Premium Newsletter Subscribers",
    "emoji": "๐Ÿ’Ž"
  }'

Error Responses

  • 404 Not Found: Contact book not found or doesn't belong to your team
{
  "code": "NOT_FOUND",
  "message": "Contact book not found"
}

Delete Contact Book

Permanently delete a contact book and all its associations. This action cannot be undone.

Endpoint: DELETE /v1/contactBooks/{id}

Path Parameters

ParameterTypeDescription
idstringUnique identifier of the contact book to delete

[!CAUTION] Deleting a contact book is permanent and cannot be undone. Make sure you want to delete this contact book before proceeding.

Response Schema

FieldTypeDescription
successbooleantrue if deletion was successful

Response Example

{
  "success": true
}

cURL Example

curl -X DELETE "https://api.unsent.dev/v1/contactBooks/clxy123abc" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json"

Error Responses

  • 404 Not Found: Contact book not found or doesn't belong to your team
{
  "code": "NOT_FOUND",
  "message": "Contact book not found"
}

Common Use Cases

Creating a Segmented Contact List

# Create a contact book for your blog subscribers
curl -X POST "https://api.unsent.dev/v1/contactBooks" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Blog Subscribers",
    "emoji": "๐Ÿ“",
    "properties": {
      "source": "blog",
      "interests": "technology"
    }
  }'

Monitoring Contact Book Growth

# Get detailed statistics for a contact book
curl -X GET "https://api.unsent.dev/v1/contactBooks/clxy123abc" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json"

Updating Contact Book Metadata

# Update properties as your segmentation evolves
curl -X PATCH "https://api.unsent.dev/v1/contactBooks/clxy123abc" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "properties": {
      "source": "blog",
      "interests": "technology",
      "engagement": "high"
    }
  }'

API Reference