Tutorial: Unsubscribe People Version 2

This tutorial demonstrates how to unsubscribe people from your email list.

Both subscribed and unsubscribed people are available over the API and in Action Network's user interface. Changing their subscription status will not change their action history or other data. They can be resubscribed if they take another action on pages you create, or if you resubscribe them via uploads, individually, or over the API.

Steps:

Find a person to unsubscribe

The first step is to find the person you want to unsubscribe. You can do that by using the OData filtering system described in the general concepts documentation here.

In this case, we'll find the person by email address:

						
GET https://actionnetwork.org/api/v2/people/?filter=email_address eq 'jdoe@mail.com'

Header:
OSDI-API-Token: your_api_key_here
										

Which will return a response like this:

						
200 OK

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


{
  "total_pages": 1,
  "per_page": 25,
  "page": 1,
  "total_records": 1,
  "_links": {
    "osdi:people": [
      {
        "href": "https://actionnetwork.org/api/v2/people/c947bcd0-929e-11e3-a2e9-12313d316c29"
      }
    ],
    "curies": [
      {
        "name": "osdi",
        "href": "https://actionnetwork.org/docs/v2/{rel}",
        "templated": true
      },
      {
        "name": "action_network",
        "href": "https://actionnetwork.org/docs/v2/{rel}",
        "templated": true
      }
    ],
    "self": {
      "href": "https://actionnetwork.org/api/v2/people"
    }
  },
  "_embedded": {
    "osdi:people": [
      {
        "given_name": "John",
        "family_name": "Doe",
        "identifiers": [
          "action_network:c947bcd0-929e-11e3-a2e9-12313d316c29"
        ],
        "created_date": "2014-02-21T17:49:59Z",
        "modified_date": "2014-02-21T17:49:59Z",
        "email_addresses": [
          {
            "primary": true,
            "address": "jdoe@mail.com",
            "status": "subscribed"
          }
        ],
        "phone_numbers": [
          {
             "primary": true,
             "number": "12021234444",
             "number_type": "Mobile",
             "status": "subscribed"
          }
        ],
        "postal_addresses": [
          {
            "primary": true,
            "address_lines": [
              "1600 Pennsylvania Ave."
            ],
            "locality": "Washington",
            "region": "DC",
            "postal_code": "20009",
            "country": "US",
            "language": "en",
            "location": {
              "latitude": 32.349,
              "longitude": -75.6771,
              "accuracy": "Approximate"
            }
          }
        ],
        "languages_spoken": [
          "en"
        ],
        "_links": {
          "self": {
            "href": "https://actionnetwork.org/api/v2/people/c947bcd0-929e-11e3-a2e9-12313d316c29"
          },
          "osdi:attendances": {
            "href": "https://actionnetwork.org/api/v2/people/c947bcd0-929e-11e3-a2e9-12313d316c29/attendances"
          },
          "osdi:signatures": {
            "href": "https://actionnetwork.org/api/v2/people/c947bcd0-929e-11e3-a2e9-12313d316c29/signatures"
          },
          "osdi:submissions": {
            "href": "https://actionnetwork.org/api/v2/people/c947bcd0-929e-11e3-a2e9-12313d316c29/submissions"
          },
          "osdi:donations": {
            "href": "https://actionnetwork.org/api/v2/people/c947bcd0-929e-11e3-a2e9-12313d316c29/donations"
          },
          "osdi:outreaches": {
            "href": "https://actionnetwork.org/api/v2/people/c947bcd0-929e-11e3-a2e9-12313d316c29/outreaches"
          },
          "osdi:taggings": {
            "href": "https://actionnetwork.org/api/v2/people/c947bcd0-929e-11e3-a2e9-12313d316c29/taggings"
          }
        }
      }
    ]
  }
}
					
Back To Top ↑

Unsubscribe the person

Once you have done your search and found your person, navigate to their individual record using the links provided and execute a PUT request, changing the status on their email address and phone number to unsubscribed, like so:

						
PUT https://actionnetwork.org/api/v2/people/c947bcd0-929e-11e3-a2e9-12313d316c29

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

{	
  "email_addresses": [
    {
      "status": "unsubscribed"
    }
  ],
  "phone_numbers": [
    {
      "status": "unsubscribed"
    }
  ]
}
					

Which will return a response like this:

						
200 OK

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


{
  "given_name": "John",
  "family_name": "Doe",
  "identifiers": [
    "action_network:c947bcd0-929e-11e3-a2e9-12313d316c29"
  ],
  "created_date": "2014-02-21T17:49:59Z",
  "modified_date": "2014-02-21T17:49:59Z",
  "email_addresses": [
    {
      "primary": true,
      "address": "jdoe@mail.com",
      "status": "unsubscribed"
    }
  ],
  "phone_numbers": [
    {
      "primary": true,
      "number": "12021234444",
      "number_type": "Mobile",
      "status": "unsubscribed"
  }
],
  "postal_addresses": [
    {
      "primary": true,
      "address_lines": [
        "1600 Pennsylvania Ave."
      ],
      "locality": "Washington",
      "region": "DC",
      "postal_code": "20009",
      "country": "US",
      "language": "en",
      "location": {
        "latitude": 32.349,
        "longitude": -75.6771,
        "accuracy": "Approximate"
      }
    }
  ],
  "languages_spoken": [
    "en"
  ],
  "_links": {
    "self": {
      "href": "https://actionnetwork.org/api/v2/people/c947bcd0-929e-11e3-a2e9-12313d316c29"
    },
    "osdi:attendances": {
      "href": "https://actionnetwork.org/api/v2/people/c947bcd0-929e-11e3-a2e9-12313d316c29/attendances"
    },
    "osdi:signatures": {
      "href": "https://actionnetwork.org/api/v2/people/c947bcd0-929e-11e3-a2e9-12313d316c29/signatures"
    },
    "osdi:submissions": {
      "href": "https://actionnetwork.org/api/v2/people/c947bcd0-929e-11e3-a2e9-12313d316c29/submissions"
    },
    "osdi:donations": {
      "href": "https://actionnetwork.org/api/v2/people/c947bcd0-929e-11e3-a2e9-12313d316c29/donations"
    },
    "osdi:outreaches": {
      "href": "https://actionnetwork.org/api/v2/people/c947bcd0-929e-11e3-a2e9-12313d316c29/outreaches"
    },
    "osdi:taggings": {
      "href": "https://actionnetwork.org/api/v2/people/c947bcd0-929e-11e3-a2e9-12313d316c29/taggings"
    }
  }
}
					

Click here for full documentation of people resources.

Back To Top ↑

Next Tutorial: Send a mass email