[Cotlet](https://cotlet.dev/index.md) · [Integrations](https://cotlet.dev/integrations.md) · [How it works](https://cotlet.dev/how-it-works.md) · [Use cases](https://cotlet.dev/use-cases.md) · [Security](https://cotlet.dev/security.md) · [For developers](https://cotlet.dev/for-developers.md) · [For automation agencies](https://cotlet.dev/for-agencies.md) · [Blog](https://cotlet.dev/blog.md) · [API docs](https://cotlet.dev/docs.md) · [Help center](https://cotlet.dev/help.md) · [Changelog](https://cotlet.dev/changelog.md) · [Contact](https://cotlet.dev/contact.md) · [Pricing](https://cotlet.dev/pricing.md) · [Sign up](https://cotlet.dev/signup)

# Create segment

> Create a segment from activity, list and contact property filters. Inputs, cURL, Python and Node.js examples and an example response.

Source: https://cotlet.dev/docs/api/mailjet/create_segment

Docs sections: [Get started](https://cotlet.dev/docs.md) · [REST API](https://cotlet.dev/docs/api.md) · [MCP](https://cotlet.dev/docs/mcp.md) · [SDKs & CLI](https://cotlet.dev/docs/sdks.md) · [Integrations](https://cotlet.dev/docs/integrations.md)

Create a segment from activity, list and contact property filters.

Mailjet API: https://cotlet.dev/docs/api/mailjet.md

`POST https://cotlet.dev/api/v1/mailjet/segments`

Access: write.

Does what Create a segment does on the Segmentation page. match "all" combines the filters with AND and "any" with OR. Pass list_id to get the number of contacts that match, as Calculate number of contacts does. The segment reaches no one and is undone by deleting it in the Dashboard, so it does not wait for your OK. Mailjet recalculates it at send time.

## Parameters

| Name | Type | Required | Description |
|---|---|---|---|
| `name` | string | yes | Name of the segment. |
| `match` | enum | no | all (AND) or any (OR). Default: all. |
| `conditions` | array | yes | Filters as {type, value}. type: campaign_opened, campaign_not_opened, campaign_clicked or campaign_not_clicked (value: campaign_id); opened_last_days, not_opened_last_days, clicked_last_days or not_clicked_last_days (value: number of days); subscribed_to_list or not_subscribed_to_list (value: list_id); property (also field, operator and value). |
| `list_id` | integer | no | List to count the matching contacts against. |

## Request

**cURL**

```bash
curl -X POST https://cotlet.dev/api/v1/mailjet/segments \
  -H "Authorization: Bearer $COTLET_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name":"Did not open: Autumn offer","match":"all","conditions":[{"type":"campaign_not_opened","value":7164820931},{"type":"subscribed_to_list","value":10234567}],"list_id":10234567}'
```

**Python**

```python
result = client.call("mailjet", "create_segment", {"name":"Did not open: Autumn offer","match":"all","conditions":[{"type":"campaign_not_opened","value":7164820931},{"type":"subscribed_to_list","value":10234567}],"list_id":10234567})
```

**Node.js**

```js
const result = await cotlet.call('mailjet', 'create_segment', {"name":"Did not open: Autumn offer","match":"all","conditions":[{"type":"campaign_not_opened","value":7164820931},{"type":"subscribed_to_list","value":10234567}],"list_id":10234567});
```

**CLI**

```bash
cotlet call mailjet create_segment --data '{"name":"Did not open: Autumn offer","match":"all","conditions":[{"type":"campaign_not_opened","value":7164820931},{"type":"subscribed_to_list","value":10234567}],"list_id":10234567}'
```

## Example response

```json
{
  "segment_id": 2938471,
  "name": "Did not open: Autumn offer",
  "match": "all",
  "conditions": 2,
  "matching_contacts": 1121,
  "list_id": 10234567
}
```

Previous: [List campaign activity](https://cotlet.dev/docs/api/mailjet/list_campaign_activity.md)
Next: [Duplicate campaign](https://cotlet.dev/docs/api/mailjet/duplicate_campaign.md)

---

Give your AI agents your signed-in browser.

**Product:** [Integrations](https://cotlet.dev/integrations.md) · [Use cases](https://cotlet.dev/use-cases.md) · [How it works](https://cotlet.dev/how-it-works.md) · [Pricing](https://cotlet.dev/pricing.md) · [Security](https://cotlet.dev/security.md)

**Resources:** [Blog](https://cotlet.dev/blog.md) · [API docs](https://cotlet.dev/docs.md) · [Help center](https://cotlet.dev/help.md) · [Changelog](https://cotlet.dev/changelog.md) · [GitHub](https://github.com/cotletdev/cotlet)

**Solutions:** [For developers](https://cotlet.dev/for-developers.md) · [For automation agencies](https://cotlet.dev/for-agencies.md)

**Company:** [About](https://cotlet.dev/about.md) · [AI info: company facts](https://cotlet.dev/ai-info.md) · [Contact](https://cotlet.dev/contact.md)

**Legal:** [Terms of service](https://cotlet.dev/terms) · [Privacy policy](https://cotlet.dev/privacy) · [Refund policy](https://cotlet.dev/refunds) · [Acceptable use](https://cotlet.dev/acceptable-use) · [Cookie policy](https://cotlet.dev/cookies) · [DPA](https://cotlet.dev/dpa) · [Subprocessors](https://cotlet.dev/subprocessors)

**Elsewhere:** [Status page](https://status.cotlet.dev) · [Cotlet on GitHub](https://github.com/cotletdev) · [Cotlet on X](https://x.com/cotletdev) · [Cotlet on LinkedIn](https://www.linkedin.com/company/cotletdev) · [Cotlet on Product Hunt](https://www.producthunt.com/products/cotlet) · [Cotlet on Crunchbase](https://www.crunchbase.com/organization/cotlet) · [Cotlet on SaaSHub](https://www.saashub.com/cotlet)

Cotlet is an independent service. It is not affiliated with, endorsed by or sponsored by any of the products listed on this site. Product names are trademarks of their respective owners.

## For AI agents: sign your user up

Is your user asking you to sign them up for Cotlet? You can do it for them, no account or key needed.

1. Read the fields and their allowed values: GET https://cotlet.dev/api/v1/access-requests
2. Ask the user for each value: email, apps, what you will do with them. If they leave the password to you, generate a strong one and show it to them.
3. Show the user what you will send, then POST it as JSON to https://cotlet.dev/api/v1/access-requests.

One call creates the account and sends the access request; we email the user when access is granted.
