SOAP API Best Practices

From $1

    Doc-Wiki-BannerHK.png

    (Click the banner to go to the related Docs.Code.ExactTarget.com page.)

    This document presents a broad conceptual overview of ExactTarget's SOAP API. Review this document to understand how the SOAP API can be used to interact with ExactTarget's application and accomplish specific tasks.

    Read this page to understand the difference between the XML and SOAP APIs offered by ExactTarget.

    Workflow Best Practices

    You can use the SOAP API to interact with the ExactTarget application and accomplish the following tasks outlined in the diagrams below:

    PreSend.png Send.png PostSend.png

    This list does not present the complete capabilities of the SOAP API, but it illustrates a common workflow for SOAP API users. You can view more specific examples of workflows:

    Sending an Email to a Subscriber List

    List_Based_Send.jpg

    Sending an Email to a Data Extension

    Send_to_Date_Extension.jpg

    Sending a Triggered Send

    Triggered_Send.jpg

    You can view more triggered send code samples here.

    Importing Data via the SOAP API

    PrepareInformation.png CreateImportDefinition.png StartImportDefinition.png
    • Create Portfolio Objects
    • Create CSV Files
    • Create Tab-Delimited Files
    • Get File Import Locations

     

     

    When you define an import activity for a data file, you provide the following information about the source file to import and the destination of the data:

    • The location where the import gets the file to import. By default, this is the Import folder of your FTP account.
    • The name of the import file. You can choose to enter a static name-such as subscribers.csv-or you can choose to include placeholder for the date. Including placeholders for the date lets you have a unique filename for each import file without changing the import activity definition before each import. For example, if you create the file naming pattern subscribers%%Month%%%%Day%%.csv, then on November 20 the import will look for a file named subscribers1120.csv.
    • The file type. You can import comma-delimited or tab-delimited files, or you can define your own delimiter.
    • The destination type. You can import the data into a subscriber list, or data extension. 
      If your ExactTarget account uses the AIM package (which is enabled by default for Enterprise 2.0 accounts) you can also import data into a publication list. 

      Subscriber attributes are not supported for publication list imports. The system only supports the following:

      • Email Address
      • Subscriber Key (if the Subscriber Key feature is enabled)
      • Status (active or unsub)
      • Reason (The unsub/opt-out reason)

    When you define an import activity for a Salesforce report or object, you provide the following information:

    • Whether you are importing an Object or a Report.
    • The Object or Report to import.
    • Whether to import all data or only new data. If you select new data, you enter the date and time after which the data should be imported. 

    When you save an import definition configured to import a Salesforce object or report, the system auto-creates the data extension according to the schema of the object or report. After the data extension is created, you cannot change the data source.

    Interaction Best Practices

    You can access the SOAP API using several different languages:

    The linked articles include instructions and sample code. A complete list of available sample code and technical articles can be found here.

    Standard API Users

    Standard API users can interact with the API to accomplish all tasks outlined above.

    Enterprise API Users

    In addition to the tasks that can be accomplished by standard API users, enterprise API users can use the API to work with different business units and account users. This includes the ability to perform the following actions:

    • Create, modify, and delete business units
    • Create, modify, and delete users
    • Set permissions and roles for users
    • Associate subscribers and lists with different business units

    More information can be found in the Managing Enterprise 2.0 Accounts with the Web Services API document.

    Embedded API Users

    Embedded API users can interact with the SOAP API in the same manner as standard API users, but they can also utilize additional functionality that allows them to control the accounts and sub-accounts of their clients. That functionality includes the following examples:

    Architecture and Coding Best Practices

    This section outlines the best practices (both in general and for specific languages) for interacting with the SOAP API.

    General

    These best practices apply in all instances, regardless of language.

    Planning

    Use the best practices below to plan for the eventualities that could be encountered with your use of the SOAP API.

    • Use the fewest amount of steps possible when moving or updating data in your SOAP API calls.
    • Use asynchronous processing whenever possible to ensure the best response to your calls.
    • Plan and map out the data flow of your API calls in order to maximize the effectiveness of your API interactions.
    • Make sure to account for future growth when implementing your API solution
    • Avoid using the XML API in your planning, as this API is in a maintenance state and will not receive additional functionality in the future.
    • Plan for peaks in traffic to your website or system and know what happens when you reach the upper limits of your system's capabilities.
    • Queue API calls and pull off data from those calls at a defined rate.
    • Perform any stress tests in the production support environment instead of the production environment.
    • Include code in your calls that retrieves the results of your call (such as the information in the CreateResult object) and responds appropriately, such as notifying you when an error occurs or taking a specific action when a successful Create call finishes.

    You can use multiple concurrent API sessions to increase overall throughput. However, note that a large number of sessions may result in diminishing returns. Test your API calls thoroughly to ensure that you are using the optimum number of concurrent API sessions.

    Maintaining Service Level Agreements

    ExactTarget agrees to maintain consistent levels of service through the use of service level agreements, or SLAs. You should observe the best practices below in order to ensure the performance outlined in your SLA:

    • Avoid sending a completely rendered email in high-volume or triggered sends.
    • Use dynamic content instead of starting a send definition, pausing it, changing the message, and restarting the send definition. This practice delivers inconsistent tracking information, no aggregate tracking data, and adds data rows to your tracking information.
    • Avoid using high-volume triggered send calls using the synchronous SOAP API. Consider using asynchronous API calls to reduce server strain.
    • Store message content in content areas instead of data extensions.
    • Use send logging instead of send-time attributes where possible.
    • Restrict the number of synchronous threads in your calls to 20 or fewer.
    • Restrict your API requests to 50 objects per synchronous call or 100 objects per asynchronous call.

    Monitoring Sends Through the SOAP API

    The best way to monitor sends through the API is by polling the Send object on the following properties:

    1. SendID (identifier for the send)
    2. SentTime (time the send completed)
    3. NumberSent (number of emails sent)

    NumberSent will increment as the send is processing. Processing will be complete once SentTime has a value.

    If you have programs enabled for your account, you can set up those programs in your account's user interface and begin the programs from the SOAP API. You can also modify the components of that program (such as import definitions and email send definitions) through the SOAP API to better define the information you would like to use in monitoring your sends. By automating these tasks, you can gain an understanding of how a send is progressing by which tasks are being executed.

    Triggered Sends

    Use the best practices outlined below to improve the performance of your triggered sends via the SOAP API.

    This logic allows you take advantage of the instant notifications of the synchronous API and the solid reliability of the asynchronous API.

    • Use data extensions with your triggered sends to store relevant subscriber information instead of subscriber lists.
    • Refrain from using unlimited-length text columns in data extension used for triggered sends.
    • Keep your triggered send batches to numbers smaller than 100 for asynchronous calls and less than 50 for synchronous calls.
    • Keep your maximum payload per call at less than 5MB.
    • Pass less than 10 attributes to avoid decreased performances.
    • Retrieve information for an HTTPGet from your own site before the triggered send in order to prevent connectivity issues and problem-causing surges of traffic.
    • Use applicable Owner information and send classifications to set the From name and email address for a triggered send instead of passing those values in at the time of the send.
    • You can use the following workflow to take advantage of both the synchronous and asynchronous SOAP API and make sure your calls process effectively:
      • Send your initial API request via the synchronous API, allowing you to receive immediate feedback if either the subscriber or request has issues
      • Retry that call up to three (3) times to account for potential timeouts or connectivity issues
      • Send failed call via asynchronous AP

    Retrieving Data from the Application

    Use data extracts to retrieve information from the system whenever possible. Examples of data extract use can be found in the articles below:

    Connection Failures and Timeouts

    You should configure your code to handle potential problems with connecting to the SOAP API. Use the best practices outlined below to help your system handle these connectivity issues:

    • Use the CorrelationID property to make sure that the SOAP API can evaluate whether a call is a continuation of a series of API calls or a repeat call made due to connection failures.
    • Make sure to set client-side timeouts in your calls. Use the following examples as models:
      • Asynchronous operations - 30 seconds
      • Synchronous operations (not including tracking retrieves) - 120 seconds
      • Synchronous operations retrieving large sets of data - 300 seconds
    • Enable client-side logging of errors so you can evaluate the reasons behind the failure of a call, even if connectivity to the SOAP API remains problematic.

    Security

    When interacting with the web service API, you should observe these best practices in order to maintain a secure connection between your integration or development environment and the ExactTarget system.

    Give Each User Separate API Credentials

    Make sure that each user interacting with the web service API has their own username and password. You can set separate permissions for each user, ensuring that users have access to only those features that they need to complete their tasks using the web service API. Credentials should not be shared between users. A single, shared API user should be used ONLY for system-based processes, and that account should have only essential permissions applied to it. All other processes should be initiated by specific users.

    Always store your API endpoint, username, and password in a configuration file. This allows you to change this information quickly without requiring you to redeploy this code.

    Restrict Integration Partner Access to Necessary Functions Only

    Integration partners should only be able to access those functions that are absolutely necessary to make the integration function. All other functions should be strictly restricted to prevent potential security issues.

    Use Strong Passwords

    All users with API access should use strong passwords.

    • Include special characters
    • Include numbers
    • Make the string as long as possible
    • Avoid predictable strings of characters

    No matter how strong your password is, you should regularly change it (either manually or by allowing your password to expire) to make it more difficult to guess or obtain your password.

    Data Management

    Use the best practices outlined below to best maintain your data.

    • Avoid simultaneously updating a list or data extension using multiple API calls.
    • Use the customer key (if available) instead of waiting to obtain an ID from a call.
    • Because SubscriberID is not exposed to batch functions, you should not use it as a unique identifier.
    • Avoid using partner properties if possible due to sunsetting of this functionality.
    • Use Key properties instead of ID properties whenever possible, as Key properties support asynchronous processing and high-availability functionality.
    • Import information in batches whenever possible.
    • If your import definition fails validation during a Delete call, run an Update call on that import definition and use the details from that call to correct the definition.
    • If you pass an attribute in a call that doesn't exist on the subscriber list or data extension, the code will not error out. However, the value for that attribute will not be passed and a new attribute will not be created. You will not receive any indication of the failure to pass the attribute and value.
    • While you can create a data extension with an external key larger than 36 characters, doing so may cause problems when using the data extension in conjunction with other processes (especially if working with the UI, which will truncate the external key to the first 36 characters). Be sure to limit your data extension external keys to 36 characters to help ensure all further processes function correctly.
    • For the best results when dealing with data/time values in your code, use a Coordinated Universal Time (UTC) offset. When retrieving dates, convert the dates to the UTC offset to ensure dates are in the format suitable for your application.
    • When retrieving information on a sub-object, be sure to specify the properties on that sub-object you wish to retrieve. For example, you must specify the ID of the Client sub-object of a Send object.

    .NET

    All optional, value-type properties of an object (such as the Int, bool, and enum types) have an additional Boolean property defined with Specified appended to the name.  This property is used to tell the XML Serializer whether the corresponding property should be included when generating the XML that will be sent.  When deserializing, this property indicates whether the corresponding property was included in the XML.  For example, the Subscriber object has an optional property called Status.  When the proxy class is generated, a "StatusSpecified" property will also be created.  When sending an object, if you specified a value for "Status", you must also set "StatusSpecified=true".  If you do not, the value of "Status" will not be serialized and sent to the server.  When receiving an object, you should check if "StatusSpecified=true".  If it is, then you know that a "Status" value was received and the data in the "Status" property is valid.  If "StatusSpecified=false", the value in "Status" will be the default value for that properties data type.

    In the following table, if you use the code in the first column, the second column shows the XML that will be generated.  If you start with the XML in the second column, the third column shows what the properties will be set to.

    .NET Code Before Serialization XML .NET Code After Serialization

    Subscriber.Status = SubscriberStatus.Bounced

    Subscriber.StatusSpecified = true

    <Subscriber>
        <Status>Bounced</Status>
    </Subscriber>
    Subscriber.Status = SubscriberStatus.Bounced
    Subscriber.StatusSpecified = true
    Subscriber Status = SubscriberStatus.Bounced

    <Subscriber>

    </Subscriber>

    Subscriber.Status = SubscriberStatus.Active

    Subscriber.StatusSpecified = false

    Subscriber.Status = SubscriberStatus.Bounced
    Subscriber.StatusSpecified = false
    <Subscriber>
    </Subscriber>
    Subscriber.Status = SubscriberStatus.Active
    Subscriber.StatusSpecified = false
    Subscriber.StatusSpecified = true

    <Subscriber>

         <Status>Active</Status>

    </Subscriber>

    Subscriber.Status = SubscriberStatus.Active

    Subscriber.StatusSpecified = true

    To avoid confusion and possible bugs in your code, you should always be explicit as indicated in the first row.

    When processing received objects, you should use the following pattern:

    if (subscriber.StatusSpecified)
    {
        Console.WriteLine(subscriber.Status);
    }
    else
    {
        Console.WriteLine("The subscriber.Status property was not set");
    }

    Synchronous vs. Asynchronous SOAP API

    You can interact with the SOAP API in either a synchronous or asynchronous manner. The SOAP API processes synchronous calls at the time they are received, while it queues asynchronous calls and processes them in a specified order. ExactTarget recommends interacting with the SOAP API asynchronously as much as possible in order to ensure that API calls can be processed in the order you desire (supporting conversations) and avoid accidentally reprocessing calls due to connection interruption.

    You can find more information about interacting asynchronously with the SOAP API in the Asynchronous Processing technical article.


    This page was last updated by Ryan Williams on Fri, 06 Jan 2012 20:45:31 GMT.

    If you require assistance with the ExactTarget application, please contact Global Support. If you wish to send Ryan direct feedback, fill out the form below:

     


    Was This Page Helpful?
    Suggestions or Comments:
    Name (optional):
    Email Address (optional):
    Enter 20445 backwards:
       
    Tags: (Edit tags)
    • No tags

     
    Powered by MindTouch 2010
    Admin