Skip to Content
1MSG
ReferenceCampaigns API

Import segment members from CSV

POST
/api/v1/campaigns/segments/{segmentId}/members/import

Replaces a manual segment's members from a multipart UTF-8 CSV upload (field file, optional BOM).

  • Columns: Header must include name plus phone and/or bsuid; any additional columns are stored in attributes (an optional attr_ prefix is stripped).
  • Row rules: Each non-empty data row requires name and exactly one of phone or bsuid (max 500 rows). Empty data rows clear the segment; blank lines are reported as soft empty_row notices without blocking import.
  • Validation & dry run: Pass ?dryRun=true to validate without writing. Hard row errors fail the entire import (imported: 0, no DB write) and return { imported, dryRun, errors: [{ row, code, message, column? }] }.
  • Automatic segments return 400 (automatic_segment_readonly).

Authorization

bearer
headerAuthorizationBearer <API key>

Key issued in Settings → Developer → API key. Inbox methods need the Inbox scope. Campaigns methods need the Campaigns scope.

Path Parameters

segmentId*string

Segment id returned by create or list.

Query Parameters

dryRun?string

When true, validate only; do not write members.

Request Body

CSV file in multipart field file.

multipart/form-data
  1. body
file*unknown

Response Body

application/json
  1. response
imported*number

How many members were written (or would be written on dryRun). 0 when hard errors blocked the import.

dryRun*boolean

True when dryRun=true was requested; no write occurred.

errors*array<>

Row/file errors. Soft codes (empty_row) do not block. Any hard error → imported=0 and no write.

Example Request
curl -X POST 'https://api.1msg.io/api/v1/campaigns/segments/string/members/import'
Example Response
{  "imported": 3,  "dryRun": false,  "errors": [    {      "row": 2,      "code": "invalid_phone",      "message": "phone must be E.164",      "column": "phone"    }  ]}