Skip to content
Pidgely Docs

Guides

Contacts, segments & audiences

Store contacts with typed properties, save the recipients of your e-mails automatically, group contacts in segments for broadcasts and automations, and keep unsubscribes in sync with the suppression list. Legacy audiences are supported.

View as Markdown

Contacts are the people you send broadcasts and automations to:

  • Contacts are global to your account and unique by email.
  • The recipients of your e-mails become contacts automatically (in the Sent mail segment), so the customers your product already e-mails are there without an import. See Automatic contacts.
  • Segments are named groups. A contact can belong to any number of segments.
  • Audiences are the legacy name for segments, kept so older code keeps working.

Contacts

Node.js
import { Pidgely } from 'pidgely';

const pidgely = new Pidgely(process.env.PIDGELY_API_KEY);

const { data, error } = await pidgely.contacts.create({
  email: 'steve@example.com',
  firstName: 'Steve',
  lastName: 'Wozniak',
  properties: {
    plan: 'pro',
    seats: 5,
    beta: true,
  },
  segments: [
    {
      id: '0199d7f5-9a3e-7d4b-a1c2-7e5f0b3d6c48',
    },
  ],
});
console.log(data ?? error);
Python
import os
import pidgely

pidgely.api_key = os.environ["PIDGELY_API_KEY"]

result = pidgely.Contacts.create({
    "email": "steve@example.com",
    "first_name": "Steve",
    "last_name": "Wozniak",
    "properties": {
        "plan": "pro",
        "seats": 5,
        "beta": True,
    },
    "segments": [
        {
            "id": "0199d7f5-9a3e-7d4b-a1c2-7e5f0b3d6c48",
        },
    ],
})
print(result)
PHP
<?php

require __DIR__ . '/vendor/autoload.php';

$pidgely = Pidgely::client(getenv('PIDGELY_API_KEY'));

$result = $pidgely->contacts->create([
    'email' => 'steve@example.com',
    'first_name' => 'Steve',
    'last_name' => 'Wozniak',
    'properties' => [
        'plan' => 'pro',
        'seats' => 5,
        'beta' => true,
    ],
    'segments' => [
        [
            'id' => '0199d7f5-9a3e-7d4b-a1c2-7e5f0b3d6c48',
        ],
    ],
]);
var_dump($result);
Go
package main

import (
	"context"
	"fmt"
	"os"

	"github.com/pidgely/pidgely-go"
)

func main() {
	ctx := context.Background()
	client := pidgely.NewClient(os.Getenv("PIDGELY_API_KEY"))

	result, err := client.Contacts.Create(ctx, &pidgely.CreateContactRequest{
		Email:     "steve@example.com",
		FirstName: "Steve",
		LastName:  "Wozniak",
		Properties: map[string]any{
			"plan":  "pro",
			"seats": 5,
			"beta":  true,
		},
		Segments: []pidgely.Segment{
			{
				Id: "0199d7f5-9a3e-7d4b-a1c2-7e5f0b3d6c48",
			},
		},
	})
	if err != nil {
		panic(err)
	}
	fmt.Println(result)
}
Ruby
require "pidgely"

Pidgely.api_key = ENV["PIDGELY_API_KEY"]

result = Pidgely::Contacts.create({
  email: "steve@example.com",
  first_name: "Steve",
  last_name: "Wozniak",
  properties: {
    plan: "pro",
    seats: 5,
    beta: true
  },
  segments: [
    {
      id: "0199d7f5-9a3e-7d4b-a1c2-7e5f0b3d6c48"
    }
  ]
})
puts result
cURL
curl -X POST 'https://api.pidgely.com/contacts' \
  -H "Authorization: Bearer $PIDGELY_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
  "email": "steve@example.com",
  "first_name": "Steve",
  "last_name": "Wozniak",
  "properties": {
    "plan": "pro",
    "seats": 5,
    "beta": true
  },
  "segments": [
    {
      "id": "0199d7f5-9a3e-7d4b-a1c2-7e5f0b3d6c48"
    }
  ]
}'
  • POST /contacts is an upsert: posting an email that already exists updates that contact.
  • first_name and last_name are up to 200 characters.
  • Properties: up to 100 per contact. Keys match ^[A-Za-z_][A-Za-z0-9_]{0,49}$; values are strings (up to 2,000 characters), numbers or booleans. Set a key to null to delete it. Reads return each property as { "value": …, "type": "string" | "number" | "boolean" }.
  • language is a standard property: the contact's preferred language as a language tag (pt-br, es, en-GB…), stored lowercase with - (pt_BR becomes pt-br; a value that is not a language tag is rejected). Sends of a template with several languages to the contact use it when the request has no template.locale.
  • Retrieve, update and delete by id or email: GET /contacts/steve@example.com works.
  • source tells how the contact was created: manual (dashboard), import (dashboard CSV import), api (an API key), store (a connected store), send (captured from an e-mail) or event (an event). Filter with GET /contacts?source=send. Captured contacts also have first_seen_at, last_seen_at and emails_received.
  • topics is not supported yet and is rejected.

Unsubscribes and the suppression list

unsubscribed and the suppression list stay in sync, both ways:

Change Effect
The contact clicks the unsubscribe link of a broadcast An unsubscribe suppression is added and the contact becomes unsubscribed: true
You set unsubscribed: true An unsubscribe suppression is added
You set unsubscribed: false The unsubscribe suppression is removed (bounce and complaint suppressions are never removed this way)
You remove an unsubscribe suppression The contact becomes subscribed again
You create a contact whose address already has an unsubscribe suppression The contact starts as unsubscribed

Suppressions are account-wide: an address that unsubscribed from broadcasts is also skipped by transactional sends. Deleting a contact keeps its suppression.

Automatic contacts from your e-mails

Every recipient of an e-mail you send (to and cc) is saved as a contact of your organization and added to the automatic Sent mail segment (Envios in Portuguese, Envíos in Spanish). It covers the API, batch sends, SMTP and template sends. Your SaaS's welcome, receipt and login e-mails build your contact list on their own, ready for broadcasts and automations.

What is captured, and what is not:

  • to and cc recipients. Never bcc.
  • Not the e-mails of broadcasts and automations (their recipients are contacts already), nor test sends from the test sender.
  • Not addresses suppressed for a bounce, a complaint or by hand. An address that unsubscribed is saved as an unsubscribed contact.
  • Addresses and patterns you exclude.

How contacts are written:

  • A new contact gets source: "send", first_seen_at, and its first and last name from the display name of the address ("Cendy Andreoli" <cendy@example.com> gives Cendy / Andreoli). Without a display name, the names stay empty.
  • An existing contact keeps its name, properties and subscription. Only last_seen_at, emails_received and its membership of Sent mail change.
  • last_seen_at is written at most once a day per contact, so a million e-mails a month to the same people costs a few writes, not a million. emails_received is approximate: it counts the e-mails seen when that daily write happens.
  • Capture runs in the background, about a minute after the send. It never slows down or fails a send.
  • New captured contacts trigger contact.created webhooks and the Contact added automation trigger (when it accepts the send source).

The Sent mail segment is managed by Pidgely: it is created with the first captured contact, shows the badge automatic in the dashboard, and cannot be renamed or deleted (409 system_segment). Its system field is sent in the API. You can still remove a contact from it.

Turning it off and excluding addresses

The capture is on by default for every organization. Owners and admins change it in Contacts → Automatic contacts (or with PATCH /contact-capture):

  • turn it off: nothing new is saved; contacts already saved stay;
  • exclude addresses or patterns, up to 100: *@yourcompany.com (your team), noreply@*, billing@partner.com. * matches any text; matching ignores case.
cURL
curl -X PATCH 'https://api.pidgely.com/contact-capture' \
  -H "Authorization: Bearer $PIDGELY_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
  "enabled": true,
  "exclude": [
    "*@fexxo.com.br",
    "noreply@*"
  ]
}'

Import the last 90 days

Recipients of e-mails sent before the capture existed can be imported once: Import recipients from the last 90 days in the dashboard (owners and admins), or POST /contact-capture/backfill. It runs in the background with the same rules, shows its progress, and can run again safely: existing contacts keep their data.

Contacts captured from your transactional e-mails are your existing customers and users, so they are saved as subscribed: you may send them relevant marketing about your own product, and every marketing e-mail (broadcasts, automations) carries the one-click unsubscribe link and List-Unsubscribe headers. Unsubscribing always works and is permanent for marketing, whatever the contact's source. Transactional e-mails keep going to them.

Segments

Create a segment, then add contacts to it:

Node.js
import { Pidgely } from 'pidgely';

const pidgely = new Pidgely(process.env.PIDGELY_API_KEY);

const { data, error } = await pidgely.segments.create({
  name: 'Newsletter',
});
console.log(data ?? error);
Python
import os
import pidgely

pidgely.api_key = os.environ["PIDGELY_API_KEY"]

result = pidgely.Segments.create({
    "name": "Newsletter",
})
print(result)
PHP
<?php

require __DIR__ . '/vendor/autoload.php';

$pidgely = Pidgely::client(getenv('PIDGELY_API_KEY'));

$result = $pidgely->segments->create([
    'name' => 'Newsletter',
]);
var_dump($result);
Go
package main

import (
	"context"
	"fmt"
	"os"

	"github.com/pidgely/pidgely-go"
)

func main() {
	ctx := context.Background()
	client := pidgely.NewClient(os.Getenv("PIDGELY_API_KEY"))

	result, err := client.Segments.Create(ctx, &pidgely.CreateSegmentRequest{
		Name: "Newsletter",
	})
	if err != nil {
		panic(err)
	}
	fmt.Println(result)
}
Ruby
require "pidgely"

Pidgely.api_key = ENV["PIDGELY_API_KEY"]

result = Pidgely::Segments.create({
  name: "Newsletter"
})
puts result
cURL
curl -X POST 'https://api.pidgely.com/segments' \
  -H "Authorization: Bearer $PIDGELY_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "Newsletter"
}'
Node.js
import { Pidgely } from 'pidgely';

const pidgely = new Pidgely(process.env.PIDGELY_API_KEY);

const { data, error } = await pidgely.contacts.segments.add({
  email: 'steve@example.com',
  segmentId: '0199d7f5-9a3e-7d4b-a1c2-7e5f0b3d6c48',
});
console.log(data ?? error);
Python
import os
import pidgely

pidgely.api_key = os.environ["PIDGELY_API_KEY"]

result = pidgely.Contacts.Segments.add({
    "email": "steve@example.com",
    "segment_id": "0199d7f5-9a3e-7d4b-a1c2-7e5f0b3d6c48",
})
print(result)
PHP
<?php

require __DIR__ . '/vendor/autoload.php';

$pidgely = Pidgely::client(getenv('PIDGELY_API_KEY'));

$result = $pidgely->contacts->segments->add([
    'email' => 'steve@example.com',
    'segment_id' => '0199d7f5-9a3e-7d4b-a1c2-7e5f0b3d6c48',
]);
var_dump($result);
Go
package main

import (
	"context"
	"fmt"
	"os"

	"github.com/pidgely/pidgely-go"
)

func main() {
	ctx := context.Background()
	client := pidgely.NewClient(os.Getenv("PIDGELY_API_KEY"))

	result, err := client.Contacts.Segments.Add(ctx, "steve@example.com", "0199d7f5-9a3e-7d4b-a1c2-7e5f0b3d6c48")
	if err != nil {
		panic(err)
	}
	fmt.Println(result)
}
Ruby
require "pidgely"

Pidgely.api_key = ENV["PIDGELY_API_KEY"]

result = Pidgely::Contacts::Segments.add({
  email: "steve@example.com",
  segment_id: "0199d7f5-9a3e-7d4b-a1c2-7e5f0b3d6c48"
})
puts result
cURL
curl -X POST 'https://api.pidgely.com/contacts/steve@example.com/segments/0199d7f5-9a3e-7d4b-a1c2-7e5f0b3d6c48' \
  -H "Authorization: Bearer $PIDGELY_API_KEY"
  • List a segment's members with GET /segments/{id}/contacts or GET /contacts?segment_id=….
  • Removing a contact from a segment keeps the contact. Deleting a segment keeps its contacts.
  • Segment names are 1–200 characters.
  • The automatic Sent mail segment (system: "sent") is the only one Pidgely manages; see Automatic contacts.

Audiences (legacy)

The /audiences endpoints are aliases of segments over the same global contacts, and broadcasts accept audience_id as an alias of segment_id.

Webhooks

Contact changes emit contact.created, contact.updated and contact.deleted webhooks with the contact's id, email, names, unsubscribed and timestamps.