POST target-lists/{listname}/members/import

Overview

The Target-List API permits interaction with target lists associated with your company.  You can use the API's POST target-list/{listname}/members/import call to add multiple members to the target list. If email address is used as the ID, it must be in lower case. Members must already exist in the database or their insertion will fail.

This is an asynchronous call and the response is a ticket with the status of the request. Once the request has been completed the response location will contain the resource for the invidiual record results. This is provided by the Async Results API.

The Async Results response payload contains the following summary information about the results of the call:

  • Counts - Requested, completed, failed, ignored and total.
  • Completed - Index value and timestamp
  • Failed - Index, timestamp and error message
  • Ignored - Index

Resource URI

 https://api.yesmail.com/v2/target-lists/{listname}/members/import

Call Description

In addition to the standard response headers, this API call will also provide a header Content-Location: https://api.yesmail.com/v2/tickets/{id}, which provides the location of the ticket resource where status information is updated. See Tickets API documenation for more details.

URI Parameters

Parameter Required Description
responseUri 

 Optional

A customer-specified URI where Yesmail’s service can post the final status of the request.  See Tickets API documentation for more details.

responseRef 

 Optional

A customer-specified value that the customer may wish to use to track the ticket internally.  See Tickets API documentation for more details.

 

Parameters

Parameter

Required

Description

errorThreshold

Optional

Optional property specifying when to stop the import process due to failures. Default is 0 or no check.

  • integer – An integer value specifying an exact error count to trigger the stop. Set to 0 (zero) to attempt import of the entire source file.
  • percent – A percentage value between > 0% and < 100% indicating when to stop processing. Percentage values must be quoted. 

importType

Required

Required property indicating how existing records are treated during the import. New records are always added.

  • ignore – Ignore the input payload and preserve the existing email and profile information for the subscriber. Think of this as a PUT with a "If-None-Match" header.
  • update – replaces only the email and profile elements that are provided in the input payload.  For any list key-value pair in the list load users list database where the key is specified in the payload, the payload value replaces the database value; any other key-values in the database are preserved.   This behaves like PUT /v2/target-lists/{listname}/members/{id}

 

HTTP Return Codes

 

Code

Description

202 Accepted

The request has been accepted.

400 Bad Request

The request could not be understood by the server due to malformed syntax at the request level.  Verify all emails are in lower case. If there are errors at the level of the individual member, but the syntax for one or more members can be understood, they will be processed correctly with a 200 OK return code, with the errors provided in the response payload as described above.

401 Unauthorized

The request requires user authentication.  Invalid Api-User and/or Api-Key header value.

404 Not Found

The target list "listname" does not exist or has been archived.

409 Conflict

This occurs when the If-Match condition is used, and the specified ETag does not match the current ETag for the resource.

413 Request Entity Too Large

The size of the request payload exceeded the maximum number of members.

Request

Importing a list of ids

{                                              
    "members": [
        {
            "id": "jsmith@zzz.com"
        },
        {     
            "id": "jsmith2@zzz.com"        
        }
    ]
}

Response

Final Ticket Reponse

{
    "state": "completed",
    "message": "finished importing job",
    "request": {
        "id": null,
        "user": "API-User header value from the request",
        "time": "2014-03-26T19:47:01.000Z",
        "uri": "https://api.yesmail.com/v2/target-lists/0008e3e1-322a-0131-e1ca-1231391c0cc2/members/import"
    },
    "events": [
        {
            "state": "accepted",
            "message": "Accepted",
            "time": "2014-03-26T19:47:01.611Z"
        },
        {
            "state": "processing",
            "message": " start importing job ....",
            "time": "2014-03-26T19:47:01.662Z"
        },
        {
            "state": "processing",
            "message": "Async Results resource created",
            "time": "2014-03-26T19:47:01.717Z"
        },
        {
            "state": "completed",
            "message": "finished importing job",
            "time": "2014-03-26T19:47:01.877Z"
        }
    ],
    "lastUpdate": "2014-03-26T19:47:01.877Z",
    "id": "53332eb5e205449d65010145",
    "response": {
        "location": "https://api.yesmail.com/v2/async-results/53332eb5e4b0e9f3a9e4c480"
    }
}

Async Results

{
    "id": "53332eb5e4b0e9f3a9e4c480",
    "lastUpdated": "2014-03-25T12:23:48.717-07:00",
    "counts": {
        "requested": 0,
        "total": 3,
        "completed": 2,
        "ignored": 1,
        "failed": 0
    },
    "completed": [
        {
            "index": 1,
            "time": "2014-03-25T12:23:48.703-07:00"
        },
        {
            "index": 2,
            "time": "2014-03-25T12:23:48.703-07:00"
        }
    ],
    "failed": [],
    "ignored": [
        {
            "index": 0
        }
    ]
}

Request

List import with personalized values

{
    "importType": "update",
    "members": [
        {
            "id": "mickey.hart@yesmail.com",
            "FIRSTNAME": "Mickey",
            "GRADUATE_DATE": "2015-09-01T22:50:49+00:00"
        },
        {
            "id": "phil.lesh@yesmail.com",
            "FIRSTNAME": "Phil",
            "GRADUATE_DATE": "2015-09-01T22:50:49+00:00"
        },
        {
            "id": "bob.weir@yesmail.com",
            "FIRSTNAME": "Robert",
            "GRADUATE_DATE": "2015-09-01T22:50:49+00:00"
        }
    ]
}

Response

Initial response

{
  "state": "accepted",
  "message": "Accepted",
  "request": {
    "id": null,
    "user": "yesmailsales",
    "time": "2015-09-02T23:19:24.000Z",
    "uri": "http://api.yesmail.com/v2/target-lists/the-band/members/import"
  },
  "response": null,
  "id": "55e783fca75e57385033f378",
  "events": [
    {
      "state": "accepted",
      "message": "Accepted",
      "time": "2015-09-02T23:19:24.120Z"
    }
  ],
  "lastUpdate": "2015-09-02T23:19:24.120Z"
}