Record Outreach Helper Version 2

This document describes the OSDI record outreach helper endpoint as implemented by the Action Network.

The record outreach helper allows you to create or update a person record and mark that person as having made an outreach on an advocacy campaign at the same time (as well as tag that person).

This saves API calls. POSTing a new outreach without the helper would mean you need a link to the person you want to associate the outreach with, which would entail either an oData search to look up the existing person or a POST using the person_signup_helper to add the person first. The record outreach helper allows you to post a person's data along with an outreach, and the helper will automatically create or deduplicate the person and then create an outreach for them on the specified advocacy campaign, all in one API call.

The record outreach helper takes the normal outreach format (described here) with an additional JSON hash with person data, and an optional array of tags to add to the person's record.

People are matched and deduplicated by email address. If a new person is created as part of a POST operation, that person will be subscribed to the email list associated with your API key. If the email address is found, that person's subscription status (subscribed, unsubscribed, etc...) will not be changed unless you pass subscribed in the status field, as described in the people documentation. In that case, the person will be subscribed to the list, even if they were previously unsubscribed. No other status fields are valid on this endpoint.

Items in the optional tags array are matched to existing tags associated with the list matching your API key by name. If a matching tag is found, that tag will be added to the person's record. If not, the tag will be ignored.

Finally, you can POST to this helper without an API key. This is useful to enable a javascript implementation, say the use of a custom form that you create, without leaking your API key to browsers. If you use unauthenticated or "blind" POST without an API key, the response will be essentially no information, to avoid leaking any personal data over the API without an API key present. You will receive a success status code and an empty JSON response if successful, or an error status code and an error message if not. See the blind post tutorial for an example.

Note: Outreaches are not deduplicated based on person, so a specific person can make more than one outreach on an advocacy campaign. In fact, a new outreach is created for each target the person sends to using our user interface, even if they send the same letter to more than one target at once. And unlike other action types, you may only post outreaches to advocacy campaign pages that have been created via the API, and these will not send autoresponses or send messages to targets. You cannot add an outreach to an advocacy campaign page created using our user interface.

Sections:

Endpoint

Endpoint:

https://actionnetwork.org/api/v2/advocacy_campaigns/[advocacy_campaign_id]/outreaches

The record outreach helper lives at the endpoint relating to the collection of outreaches on a specific advocacy campaign.

Back To Top ↑

Field names and descriptions

Record Outreach Helper fields:
Field Name Type Required on POST Description
identifiers strings[] An array of identifiers in the format [system name]:[id]. Must be globally unique. See the general concepts document for more information about identifiers.
subject string The subject of the letter that the activist wrote to the targets.
message string The message that the activist wrote to the targets.
targets Targets[] An array of hashes identifying the targets of the outreach. Must always be an array of one.
action_network:referrer_data Referrer Data A hash of referrer data such as source code and referrer code. Action Network-only.
person Person* Yes A hash representing person data to associate with this outreach. You can use any valid fields for person resources. An email address is required. See the people document for more information about people.
add_tags strings[] An array of strings representing tags to add to the person's record.
Target fields:
Field Name Type Required on POST Description
title string The title of the target of this outreach. (ex: "Senator")
given_name string The first or given name of the target. (ex: "John")
family_name string The last or family name of the target. (ex: "Smith")
ocdid string The Open Civic Data Division ID for this target's political geography, if applicable. Click here for more documentation. (ex: "ocd-division/country:us/state:ny/cd:18", which corresponds to New York's 18th Congressional District)
Referrer Data fields:
Field Name Type Required on POST Description
source string The source code of this outreach. Equivalent to someone taking action with the url argument ?source=[your source]. Corresponds to the sources chart in this action's manage page. Action Network-only.
referrer string The referrer code of this outreach. Equivalent to someone taking action with the url argument ?referrer=[your referrer code]. Must be a valid Action Network referrer code. Read-only. Corresponds to the referrers chart in this action's manage page. Action Network-only.
website string The website referrer for this outreach. Equivalent to someone taking action after clicking a link on the listed website. Corresponds to the websites chart in this action's manage page. Action Network-only.
Back To Top ↑

Related resources

Back To Top ↑

Scenario: Creating a new outreach (POST)

If you post with an inline person hash instead of with a link to a person object as described here, we will create or update the matching person and associate them with a new outreach on the specified advocacy campaign, all in one API call.

An email address is the only required field, though others can be POSTed.

People are matched and deduplicated by email address. If a new person is created as part of a POST operation, that person will be subscribed to the email list associated with your API key. If the email address is found, that person's subscription status (subscribed, unsubscribed, etc...) will not be changed unless you pass subscribed in the status field, as described in the people documentation. In that case, the person will be subscribed to the list, even if they were previously unsubscribed. No other status fields are valid on this endpoint.

Either way, outreaches are not deduplicated by person, so a person can make an outreach on an advocacy campaign more than once. In fact, a new outreach is created for each target the person sends to using our user interface, even if they send the same letter to more than one target at once.

Tags can also be added to a person's record when POSTing using the helper by including the optional tags array. Items in the array are matched to existing tags associated with the list matching your API key by name. If a matching tag is found, that tag will be added to the person's record. If not, the tag will be ignored.

Finally, you can POST to this helper without an API key. This is useful to enable a javascript implementation, say the use of a custom form that you create, without leaking your API key to browsers. See the blind post tutorial for an example.

Note: Unlike other action types, you may only post outreaches to advocacy campaign pages that have been created via the API, and these will not send autoresponses or send messages to targets. You cannot add an outreach to an advocacy campaign page created using our user interface.

Here is an example of posting an outreach with person data inlined to the special record_outreach_helper link on the outreaches collection, along with tags:

Request

						
POST https://actionnetwork.org/api/v2/advocacy_campaigns/f77e736b-d295-4e68-96ec-a765090c6523/outreaches

Header:
Content-Type: application/json
OSDI-API-Token: your_api_key_here
						

{
  "identifiers": [
    "free_advocacy:2"
  ],
  "targets": [
    {
      "given_name": "Joe",
      "family_name": "Schmoe"
    }
  ],
  "person" : {
    "family_name" : "Smith",
    "given_name" : "John",
    "postal_addresses" : [ { "postal_code" : "20009" }],
    "email_addresses" : [ { "address" : "jsmith@mail.com" }]
  },
  "add_tags": [
    "advocate",
    "member"
  ]
} 
					

Response

						
200 OK

Content-Type: application/hal+json
Cache-Control: max-age=0, private, must-revalidate


{
  "identifiers": [
    "free_advocacy:2",
    "action_network:38ec0365-f996-42a0-b26a-dbed24cf927f"
  ],
  "created_date": "2014-03-27T17:58:45Z",
  "modified_date": "2014-03-27T17:58:45Z",
  "type": "email",
  "targets": [
    {
      "given_name": "Joe",
      "family_name": "Schmoe"
    }
  ],
  "action_network:person_id": "c945d6fe-929e-11e3-a2e9-12313d316c29",
  "action_network:advocacy_campaign_id": "f77e736b-d295-4e68-96ec-a765090c6523",
  "_links": {
    "self": {
      "href": "https://actionnetwork.org/api/v2/advocacy_campaigns/f77e736b-d295-4e68-96ec-a765090c6523/outreaches/38ec0365-f996-42a0-b26a-dbed24cf927f"
    },
    "osdi:advocacy_campaign": {
      "href": "https://actionnetwork.org/api/v2/advocacy_campaigns/f77e736b-d295-4e68-96ec-a765090c6523"
    },
    "osdi:person": {
      "href": "https://actionnetwork.org/api/v2/people/17be9a36-bb9a-4f68-94a8-40523b9dab27"
    },
    "curies": [
      {
        "name": "osdi",
        "href": "https://actionnetwork.org/docs/v2/{rel}",
        "templated": true
      },
      {
        "name": "action_network",
        "href": "https://actionnetwork.org/docs/v2/{rel}",
        "templated": true
      }
    ]
  }
}
					

In the above example, a new person was created and their outreach added to the advocacy campaign at the same time. The tags "advocate" and "member" were added to that person's record as well. We deduplicate people added this way by email address, so if the email posted corresponded with a person already in the system, we would update their record instead of creating a new person. The required fields for person remain the same -- email address and postal code -- and any posts missing that information will fail.

If the person is new, they will be subscribed to the list associated with your API key. If not, their subscription status (subscribed, unsubscribed, etc...) will not be changed unless you pass subscribed in the status field, as described in the people documentation. In that case, they will be subscribed to the list, even if they were previously unsubscribed. No other status fields are valid on this endpoint.

Of course you can POST an outreach with more fields such as address lines for your inline person data or custom fields if you'd like, but they are not required. And you can omit your API key, in which case the response will a success status code and an empty JSON object if successful, or an error code and message if not.

Back To Top ↑