Mailchimp Audiences BatchSubscribe

Mailchimp Audiences BatchSubscribe

Certified

Subscribe or update many members of a Mailchimp audience

Reads an ION file from internal storage row by row and sends the members to POST /lists/{listId} in chunks of chunkSize (500 at most, Mailchimp's limit), one request after the other. The file is streamed, never loaded in memory.

Each row needs emailAddress and status (subscribed, unsubscribed, cleaned, pending or transactional), and may have mergeFields (object) and tags (list of names). The whole file is checked before the first request, so a bad row fails the task before anything is sent and the message names the 1-based row number.

Mailchimp answers 200 even when some members were rejected; those are reported in errors. By default (failOnError: true) the task fails after all chunks were sent if any member was rejected. A failed request (for example a 5xx) fails the task at once and is never retried, because replaying a POST could repeat work; the message tells how many chunks had already succeeded so you can resume. Retries only apply to 429. An empty file makes no request.

Only add contacts who have opted in; you are responsible for GDPR and Mailchimp terms.

yaml
type: io.kestra.plugin.mailchimp.audiences.BatchSubscribe

Subscribe a list of members.

yaml
id: mailchimp_batch_subscribe
namespace: company.team

tasks:
  - id: subscribe
    type: io.kestra.plugin.mailchimp.audiences.BatchSubscribe
    apiKey: "{{ secret('MAILCHIMP_API_KEY') }}"
    listId: "a1b2c3d4e5"
    from:
      - emailAddress: jane.doe@example.com
        status: subscribed
        mergeFields:
          FNAME: Jane
        tags:
          - newsletter
      - emailAddress: john.doe@example.com
        status: pending
    updateExisting: true
    failOnError: false

Subscribe the rows of an ION file, here the members of another audience.

yaml
id: mailchimp_copy_audience
namespace: company.team

tasks:
  - id: members
    type: io.kestra.plugin.mailchimp.audiences.ListMembers
    apiKey: "{{ secret('MAILCHIMP_API_KEY') }}"
    listId: "a1b2c3d4e5"
    status: SUBSCRIBED
    fetchType: STORE

  - id: subscribe
    type: io.kestra.plugin.mailchimp.audiences.BatchSubscribe
    apiKey: "{{ secret('MAILCHIMP_API_KEY') }}"
    listId: "f6g7h8i9j0"
    from: "{{ outputs.members.uri }}"
Properties

Members to subscribe

Structured data items can be defined in the following ways:

  • A single item as a map (a document).
  • A list of items as a list of maps (a list of documents).
  • A URI, supported schemes are kestra for internal storage files, file for host local files, and nsfile for namespace files.
  • A JSON String that will then be serialized either as a single item or a list of items. Each item is one member with emailAddress and status, and optionally mergeFields and tags.

Audience ID

Mailchimp audience (list) id, found in the audience settings or with ListAudiences.

OAuth access token

Set exactly one of apiKey or accessToken. server is required with an access token.

Mailchimp API key

Set exactly one of apiKey or accessToken. The data center is taken from the key suffix (for example -us19) unless server is set.

Assets this task consumes as inputs or produces as outputs, for lineage tracking and the asset graph (Enterprise Edition). A flow declaring this property on a task is rejected in the open-source edition.

Definitions
assetFailureBehaviorstring
Possible Values
IGNOREFAILWARN

Asset failure behavior

Behavior applied to the task state when a declared asset fails to render, emit, or be persisted (e.g. a lock conflict): FAIL escalates it to FAILED, WARN (default) warns it if it would otherwise succeed, IGNORE leaves the state untouched.

enableAutobooleanstring

Whether to auto-register assets referenced dynamically at runtime that are not statically declared in inputs or outputs.

inputsarray

The assets consumed as inputs.

id*string
Min length1
typestring
outputs

The assets produced as outputs.

id*string
Min length1
Max length150
type*object
descriptionstring
displayNamestring
metadataobject
Default{}
namespacestring
Min length1
Max length150
id*string
Min length1
Max length150
type*object
descriptionstring
displayNamestring
metadataobject
Default{}
namespacestring
Min length1
Max length150
id*string
Min length1
Max length150
type*object
descriptionstring
displayNamestring
metadataobject
Default{}
namespacestring
Min length1
Max length150
id*string
Min length1
Max length150
type*object
descriptionstring
displayNamestring
metadataobject
Default{}
namespacestring
Min length1
Max length150
id*string
Min length1
Max length150
type*object
descriptionstring
displayNamestring
metadataobject
Default{}
namespacestring
Min length1
Max length150
id*string
Min length1
Max length150
type*string
Min length1

Custom asset type

descriptionstring
displayNamestring
metadataobject
Default{}
namespacestring
Min length1
Max length150

Base URL override

Replaces https://<server>.api.mailchimp.com/3.0. The credential is sent to this URL, so it must be an https *.api.mailchimp.com host.

Default500

Chunk size

Members per request, between 1 and 500. Default 500.

Defaulttrue

Fail on error

Fail the task, after all chunks were sent, when Mailchimp rejected members. When false, they are returned in errors. Default true.

Default3

Max retries

Retries done by this plugin on HTTP 429 (all methods) and on 5xx or I/O errors (GET and PUT only), with exponential backoff. Default 3, between 0 and 10. Kestra's HTTP client also replays a GET or PUT once after a 429 or 503 on its own, so 0 only turns off the plugin's retries.

Data center

Mailchimp data center such as us19. Required with accessToken, optional with apiKey (overrides the key suffix).

Skip duplicate check

Do not check the batch for duplicate emails (skip_duplicate_check).

Skip merge validation

Accept members with missing required merge fields (skip_merge_validation).

Sync tags

Replace the tags of existing members by the ones in the file (sync_tags).

DefaultPT2M

Request timeout

Idle read timeout of each call: how long to wait without receiving data. Default PT2M, must be positive. Mailchimp itself cuts requests off after 120 seconds.

Update existing

Update members that already exist (update_existing). Mailchimp's default is false: existing members are then reported as errors.

Default0

Batches

Number of HTTP requests sent.

Default0

Error count

Members rejected by Mailchimp (error_count), summed over all requests.

Errors

Rejected members with Mailchimp's message and code, capped at 1000 entries. Mailchimp may list fewer than errorCount; errorCount is always the full total.

Definitions
emailAddressstring

Email address

Email of the rejected member.

errorstring

Error

Mailchimp's message.

errorCodestring

Error code

Mailchimp's error code, e.g. ERROR_CONTACT_EXISTS.

Default0

Created

Members created, summed over all requests.

Default0

Updated

Members updated, summed over all requests.