The XML-RPC API is no longer under active development. While it is still supported, no further improvements or changes will be made to it.

We strongly recommend that you use the REST API instead.


Targets are the elected officials, private citizens, companies or organizations to whom you direct your petitions, calls and letters.


Targets are divided into several types - house, senate, state_house, state_senate, and other. You can only update ( save or create ) Targets of type other via the API.

Targets are organized into groups, CongressTargetGroups or SpecialTargetGroups. TargetGroups define the subset of officials or other targets your action is trying to influence.

CongressTargetGroups have rules about finding elected officials, e.g. all Democrats elected to Congress from PA. CongressTargetGroups can include Targets of type 'house', 'senate', 'state_house', and 'state_senate'. You might create a CongressTargetGroup for all the key votes on an upcoming piece of legislation. Or for all the Democrats in the U.S. House in a specific list of states.

SpecialTargetGroups can be anyone.

You can search for CongressTargets by zip, district and user. ActionKit gives you access to legislators in the U.S. House and U.S. Senate, as well as state House and state Senate.

CallPages, LetterPages and PetitionPages can have one or more TargetGroups associated with them. You can add and remove TargetGroups from Pages using the API.


The base class for all Target objects.


Target objects all have the following fields, which map to columns in the core_target table:

  • type - house, senate, state_house, state_senate, other
  • country
  • state
  • seat - For senators at the federal and state level
  • us_district - For representatives at the federal and state level
  • district_name - Friendly name of district (US and International)
  • title
  • long_title
  • first
  • last
  • phone
  • fax
  • email
  • gender - In the admin this field is labeled "Pronouns" but identified in the database as "gender". Options are Null for They/Them/Theirs; M for He/Him/His; or F for She/Her/Hers
  • party - D, R and I are standard.


Targets support the common API methods with a few changes, notably that save, create and save_or_create only allow changes to Targets of type other. See the Target for the details.

Targets also support a number of methods to help using them in text. See TargetList for more details.


>>> actionkit.Target.get(dict(us_district='PA_07', type='house'))
{'country': 'United States',
 'email': 'https://meehan.house.gov/contact-me/email-me',
 'fax': '(202) 226-0280',
 'first': 'Patrick',
 'gender': 'M',
 'id': 7808,
 'last': 'Meehan',
 'long_title': 'Representative',
 'party': 'R',
 'phone': '(202) 225-2011',
 'seat': '',
 'state': 'PA',
 'title': 'Rep.',
 'type': 'house',
 'us_district': 'PA_07'}


You can only create or update (save) Targets of type 'other'. For all other changes, please contact ActionKit.


Submitting your fixes to the legislative data to ActionKit allows us to share the fixes with all our clients and to make sure our vendors get the updates as well.

>>> actionkit.Target.create(dict(first='Mr.', last='Smith', type='other'))
{'country': '',
 'email': '',
 'fax': '',
 'first': 'Mr.',
 'gender': '',
 'id': 8141,
 'last': 'Smith',
 'long_title': '',
 'party': '',
 'phone': '',
 'seat': '',
 'state': '',
 'title': '',
 'type': 'other',
 'us_district': ''}


Save requires the id of the target you want to update. You an only update Targets of type 'other'. For all other changes please submit a request to ActionKit.

>>> actionkit.Target.save(dict(id=8141, phone='212 555 1212'))
{'country': '',
 'email': '',
 'fax': '',
 'first': 'Mr.',
 'gender': '',
 'id': 8141,
 'last': 'Smith',
 'long_title': '',
 'party': '',
 'phone': '212 555 1212',
 'seat': '',
 'state': '',
 'title': '',
 'type': 'other',
 'us_district': ''}


Find a U.S. Congressional District using a zip code.


Zip codes may be in several districts! ActionKit will return the largest district in a zip code. For more precise results, provide a plus-4.

>>> actionkit.Target.zip_to_district(dict(zip='19130'))
>>> actionkit.Target.zip_to_district(dict(zip='19130',plus4='3036'))


Find the city and state for a zip code:

>>> actionkit.Target.zip_to_city_and_state(dict(zip='19130'))
{'city': 'Philadelphia', 'state': 'PA'}


Find some more information about a zip:

>>> actionkit.Target.zip_details(dict(zip='19130'))
{'city': 'Philadelphia',
 'county': 'Philadelphia',
 'latitude': 39.968499999999999,
 'longitude': -75.173100000000005,
 'state': 'PA'}


CongressTargetGroups allow you to define a set of Targets based on the Targets elected office, state, or party. You can also explicitly include or exclude Targets from a CongressTargetGroup.


  • type - house, state_house, senate, state_senate, other
  • name - a unique name
  • include_republicans - True or False
  • include_democrats - True or False
  • include_independents - True or False
  • states - a list of state codes, separated by commas or semi-colons
  • targets - a list of Targets to include
  • excludes - a list of Targets to exclude

Built-in CongressTargetGroups

ActionKit has three built in CongressTargetGroups, U.S. House, U.S. President, U.S. Senate. State House and Senate are also available although you have to 'activate' them by creating a CongressTargetGroup if you want to see them in admin.



Use all_targets to load a TargetList of the full set of Targets from a TargetGroup. This isn't very useful for the built-in TargetGroups, but it works:

us_house = actionkit.CongressTargetGroup.all_targets(dict(
    name='U.S. House'

It's more useful when you've defined a TargetGroup and are not limiting signatures to constituents. See create below for an example.


In some cases you want to find the Rep. for a specific User.

>>> user = actionkit.User.get(dict(email='actionkit@example.com'))
>>> targets = actionkit.CongressTargetGroup.targets_for_user(dict(
...                       name='U.S. House', user=user['id']
...                    ))
>>> targets['title_last']
'Rep. Nadler'

The same code may return two senators, but title_last will still be defined because it returns a TargetList:

>>> user = actionkit.User.get(dict(email='actionkit@example.com'))
>>> targets = actionkit.CongressTargetGroup.targets_for_user(dict(
...       name='U.S. Senate', user=user['id']
... )
>>> targets['title_last']
'Sens. Schumer and Gillibrand'


TargetGroups become much more interesting when you define your own. Let's say you're running a campaign to support Democratic State Senators in Wisconsin.

tg = actionkit.CongressTargetGroup.create({'include_democrats':True,
                                           'name':"Wisconsin 14"})

Now you can easily get a TargetList of these Senators using the name "Wisconsin 14":

thefourteen = actionkit.CongressTargetGroup.all_targets(dict(
                       name='Wisconsin 14'
print thefourteen['count']
# 14

CongressTargetGroups that you create also support the method targets_for_user.


You can include or exclude specific Targets from your CongressTargetGroups to create more complicated (or targeted!) groups.

Targets expects a repetively named argument 'targets', which should be a list of ids, and a name or id argument of the CongressTargetGroup.

>>> tg = actionkit.CongressTargetGroup.create(dict(name='My Target Group'))
>>> target = actionkit.Target.get(dict(us_district='PA_07', type='house'))
>>> actionkit.CongressTargetGroup.targets(dict(
...         name='My Target Group',
...         targets=[target['id']]
... ))


Exclude Targets when you are targeting a large group of legislators, but want to exclude a few. For example, if you are trying to get a group of legislators to sign a letter, you could exclude those who have already signed.

Exclude expects an argument named targets, a list of ids, and a name or id of the CongressTargetGroup.

>>> pa_reps = actionkit.CongressTargetGroup.create(dict(
...                 name="PA State House Ds Who Hate Clean Water",
...                 type='state_house',
...                 include_democrats=True,
...                 include_republicans=False,
...                 include_independents=False,
...                 states='PA'
...           ))
>>> friendlies = actionkit.Target.search(dict(
...                type='state_house',
...                party='D',
...                state='PA'
...                last='Niceguy'
...              ))
>>> actionkit.CongressTargetGroup.excludes(
...     name="PA State House Ds Who Hate Clean Water",
...     targets=[ t['id'] for t in friendlies ]
... )

You can set includes and excludes on any CongressTargetGroup that's not read-only. If you include and exclude the same Target, the Target will be excluded.

You can clear excludes by calling the method with an empty list.


SpecialTargetGroups are based on arbitrary lists of Targets. They do not support filtering Targets by party, state or type.

You assign SpecialTargets to a SpecialTargetGroup by setting the 'body' parameter in the create for SpecialTargets to the id of the SpecialTargetGroup. See the example in create below.



Create a new SpecialTargetGroup, 'name' is the only parameter required or allowed.

myspecialtargetgroup = actionkit.SpecialTargetGroup.create(dict(
       name='My Custom Targets',


Add targets to a SpecialTargetGroup. If called without the targets parameter, it will return a list of the targets, but see all_targets if you want a TargetList. If called with the targets parameter, it will add the SpecialTargets to the SpecialTargetGroup.

targets = actionkit.SpecialTargetGroup.targets(dict(
            name='My Custom Targets',
            targets=[{ 'title': 'Rep',
                'first': 'Dymondia',
                'last': 'Margaretae',
                'phone': '2125551212',
                'fax':   '2125551212',
                'email': 'dymondia@example.com',
                'gender': 'F' },
            { 'title': 'Rep',
                'first': 'Dasylirion',
                'last': 'Wheeleri',
                'phone': '2125551212',
                'fax':   '2125551212',
                'email': 'dasylirion@example.com',
                'gender': 'M', }


Return the full list of SpecialTargets as a TargetList.

targets = actionkit.SpecialTargetGroup.all_targets(dict(
             name='My Custom Targets', ))

print targets['title_last'] # Reps Margaretae and Wheeleri


Delete the SpecialTargets in the SpecialTargetGroup from the database.

    name='My Custom Targets', ))


TargetLists provide additional fields to make it easier to merge references to Targets into text. The field names don't adjust, but the values are pluralized, conjugated or inflected for the number and gender of the Targets. For example, the value associated with 'them' maybe set to he, she or them.


TargetLists are currently only available in English. That's lame and we hope to change it soon!


* are
* arent
* checkboxes_html
* count
* do
* dont
* es
* es_verb
* first
* full_name
* have
* havent
* last
* listing_html
* options
* plural
* s
* s_verb
* targets
* their
* theirs
* them
* they
* title_full
* title_last
* were
* werent

TargetLists are returned by the all_targets and targets_for_user methods. You can also create a TargetList from a list of Target ids.



senate = actionkit.Target.search(dict(
          type='senate', state='PA'))
senators = actionkit.TargetList.create(dict(
  targets=[ t['id'] for t in senate]))

house = actionkit.Target.search(dict(
          type='house', state='PA', us_district='PA_07'))
representatives = actionkit.TargetList.create(dict(
  targets=[t['id'] for t in representatives]))

print "Will you call %s to ask %s to sing at the party this weekend?" % \
      (senators['title_last'], senators['them'])
# Will you call Sens. Casey and Toomey to ask them to sing at the party this weekend?

print "Will you call %s to ask %s to sing at the party this weekend?" % \
      (representatives['title_last'], representatives['them'])
# Will you call Rep. Meehan to ask him to sing at the party this weekend?

Pages With Targets

You can use the API to associate TargetGroups with Pages. Call, Petition and Letter pages can be associated with one or more TargetGroups.

Here's an example of creating two TargetGroups, associating them with a Petition and finding Targets for a specific user.

# Create a list of TargetGroups
pa_democrats = [ actionkit.CongressTargetGroup.create(dict(
         name='PA Representatives',
         name='PA Senators',
     )), ]

 # Create a PetitionPage and attach the TargetsGroups to it
 petition = actionkit.PetitionPage.create(dict(

 target_groups = actionkit.PetitionPage.set_target_groups(dict(
     target_groups=[ p['id'] for p in pa_democrats ],

 # Find the full list of Targets for the Petition:
 targets = actionkit.PetitionPage.all_targets_by_type(dict(

 # Find the specific targets for a user for the Petition
 user = actionkit.User.create(dict(
     name='Juncus Acutus',

 target_list = actionkit.PetitionPage.target_list_for_user(dict(
     id=petition['id'], user=user['id']))

 print "Your targets are %s " % (target_list['title_last'],)
 # Your targets are Rep. Fattah and Sens. Casey and Toomey


Call Pages, Petition Pages and Letter Pages have the following methods related to Targets.


Returns the current TargetGroups set for this page.

target_groups = actionkit.PetitionPage.set_target_groups(dict(
            name='savethecacti' ))


Sets the TargetGroups for this page, clearing any previously associated TargetGroups.

target_groups = actionkit.PetitionPage.set_target_groups(dict(
                target_groups=[ p['id'] for p in pa_democrats ],

See retarget_actions below.


Returns a struct of all the possible Targets for this Page categorized by type. Possible types are 'house', 'senate', 'state_house', 'state_senate', and 'other'.

targets = actionkit.PetitionPage.all_targets_by_type(dict(


Returns a TargetList of the Targets for a specific user. For state level targets, the user must have a plus4 on their zip.


Without a plus4, it's not always clear which US congressional district a user lives in. You may want to give your users a way to provide a full address or to pick a representative to deal with ambiguous cases.

target_list = actionkit.PetitionPage.target_list_for_user(dict(
            id=petition['id'], user=user['id']))


Updates the actions taken to match the current targets.

You can call this method after calling set_target_groups, or you can let ActionKit retarget automatically when you save the page or deliver the signatures.

Returns a count of actions to be retargeted. The actual retargeting will run after this call returns.

estimate = actionkit.LetterPage.retarget_actions(dict(name='mypage'))

See also api.actionkit.LetterPage.retarget_actions()


Returns an approximate number of actions to be retargeted.

Note that we only calculate an estimate based time of the last change to the targeting. Even after a call to retarget_actions this count will include actions that cannot be updated to a new target.

estimate = actionkit.LetterPage.actions_with_stale_targets(dict(name='mypage'))
print "Approximately %s actions are stale." % (estimate)

See also api.actionkit.LetterPage.actions_with_stale_targets()