We're thrilled to see all the great development going on with the NationBuilder API, and want to open this forum up for public feedback, helps and hints, questions and more. This resource is curated by the NationBuilder API Team - our goal is developers helping developers, so we definitely want to hear from you. You can also use the tags to rank posts. Thanks!
Search people by precinct?
Is it possible to search for people by precinct? I'd like to use the API to find all people in a given precinct, so that I can build a strikethrough system for election day.
Thanks
Sending email blasts using the API
Hi,
I was wondering if it's possible to send email blasts through the NationBuilder API.
We currently assemble our newsletter in our CMS (Drupal), and then send out the generated HTML page using our mailing list provider's API, from within Drupal. Is this possible with the NationBuilder API? And if not, is this something you are planning to add to the API?
Thanks!
Set address used as primary address
Using the API, how can I update which address is currently used as the primary address? e.g. mailing, home, billing, ... It would also make sense if the person object included which address is currently set as the primary address. This is helpful to know which address to update.
submitted
It isn't possible to change which address is the primary address via the API. If it is not set manually in the control panel, the primary address is set automatically to the first present address in this hierarchy:
1. home
2. registered
3. billing
4. work
5. mailing
6. user-submitted
7. Twitter
If you wish a different address to be the primary for a group of records, you would need to run a batch update in the control panel.
Set date when awarding social capital
I would like to be able to set the date when awarding social capital. More importantly I would like to do this through the API.
The reasoning for this is that if we manually award SC for somebody who volunteered to work a shift at one of our events, we would like the date that the SC was awarded to be the same date as the event. We actually have a backlog of SC that I was planning on importing using the API and just realized that I can't set the award date.
Sites index returns null for domain
api/v1/sites returns 'null' for domains for all sites, regardless of if the site has a domain set.
completed
4/28/17
This issue has been fixed.
This is a confirmed bug but does not have a set timeline on when it will be fixed. Please follow this cards if you would like to receive email updates about the status of this issue.
Subscribe to list widget
I want to add a box to my site that allows users to sign up for a mailing list that we are now migrating to NationBuilder.
My site is Python/Django. I have this already set up with Mailchimp.
The Python Quickstart doc doesn't explain what the variables 'code' or 'REDIRECT_URI' are or how they should function in step 4.
This should be pretty basic functionality. Am I missing something? Is there a simpler way to implement this?
completed
Brett, for a single-nation use, just use an app test token - you can find that in your nation's control panel under Settings > Apps.
Suggestion: Address fields as parameters on the people/search endpoint.
At the moment, you can GET people/search with geographical filters City and State. It would be nice to able to also filter (for instance) on Address 1, or Street Number, Name, and Type, or ZIP. (ie. we would like to see more geographical / primary address filters exposed through the API.)
considering
This is something we will consider but does not have a timeline at the moment.
Survey API endpoints
Is the survey aspect of the API live? When I try to update survey questions I get this response back:
{
"code":"not_found",
"message":"Record not found"
}
I am using this json to pass it through:
{
"survey_response": {
"survey_id": 1,
"person_id": 2,
"question_responses": [{
"question_id": 2,
"response": 1
}, {
"question_id": 1,
"response": "yes"
}, {
"question_id": 3,
"response": "cool"
}]
}
}
Survey API not correct
http://nationbuilder.com/surveys_api
Copying and pasting example code to create a survey generates a warning message. Adding an extra status - associated with the survey as opposed to the question it then works.
http://nationbuilder.com/surveys_api
completed
Luke,
Thanks for the feedback. There was a missing 'status' for the survey page in the example code. It should work now.
Swagger / OpenAPI Spec
I can't find any api documentation of type Swagger or OpenApi specification. Is there a hidden one ? If not, could you add one ? Thank you
Tags - does not include
I need to be able to sort for people without a specific tag. Can you please add that option?
Tags Endpoint Doesn't Accept Forward Slashes
I'm trying to use the GET /tags/:tag/people endpoint, searching for a tag such as "Ajax/Bowmanville" and getting a 404 response. It works fine with a tag like "Ajax-Pickering" which doesn't have the front slash. I've tried replacing the front slashes with %2F, as suggested here http://nationbuilder.com/mdunbar50/issue_with_space_and_in_people_tags_search but it doesn't help. Any advice would help! Thanks
considering
We have confirmed this bug but do not have a timeline for when a fix for this issue will be implemented. But we've noted it and will post any updates here.
Testing how to post here
This is the test )
Test Token Example
You have great examples on how to navigate the minefield that is OAUTH, but now that you have test tokens, I'd like to see some simple example code on how to use the test token (python/php or even curl).
Thanks
Dennis
completed
curl https://[slug].nationbuilder.com/api/v1/people/search?access_token=[my test token here] -X GET -H “Content-Type: application/json” -d ‘{"first_name":"Arion"}’
Theme API to Support Easy Theme Creation / Updates
Trying to do shared Authentication but coming up blank
I have a need to integrate my Nation with an external system also hosted by us (on the same domain as our nation). The external system has user records and its own authentication. The external ids of these records are also present in our Nation.
What I really want is that when a user signs in to the external system they also sign in to our nation - i.e. I want a shared signon, but I cannot see any practical way of doing so.
Is there any avenue I can follow towards making this happen at all?
completed
David,
SSO might be the best solution here. It is an option available to enterprise customers. Please contact your community strategist to discuss implementation.
Unable to use Import or People API with non-ascii characters (ie. á or ë with accents)
Hello. We're unable to import an CSV via the Import API, or update users via the People api when they have a name with a non-ascii character.
For example, if we post this JSON to the People API:
{
"person": {
"email": "[email protected]",
"last_name": "José",
"first_name": "Böb",
"sex": "M",
"signup_type": 0,
"employer": "Dexter Labs",
"party": "P",
"registered_address": {
"state": "TX",
"country_code": "US"
}
}
}
we receive a 400 Bad Request response. Can you please advise?
completed
When sending your request please set the content type in the header to Charset=UTF-8. For example, this is what the full header would look like:
--header "Content-Type: application/json; Charset=UTF-8"
Unsubscribe Handling?
What's the best way to unsubscribe a person from the email list? Update the Person record and set an unsubscribed_at timestamp?
Can we receive a webhook when unsubscribes happen on your side? Or does person.updated already trigger for unsubscribes?
We're looking at propagating unsubscribes that happen on our system into NationBuilder.
Nathan
completed
Hi Nathan,
Using the API, the way of unsubscribing a person would be to change the email_opt_in value on a person resource to false, this would set the unsubscribed_at timestamp automatically to the time at which the change is pushed back to the profile in the nation.
Additionally, while there isn't a webhook for unsubscribes, the person_changed webhook will fire when someone's email preferences change in the nation.
I hope this helps,
Alex
updated_at and contacted_at issues and etc.
Hello,
We are posting update as following, however do not see the note's time-stamp as posted. The note time always says "5 days ago". Also we do not see 'contacted_by' on the page.
{
"person": {
"updated_at": "2014-08-26T14:57:16-04:00",
"last_contacted_at":"2014-08-26T14:49:27-04:00",
"last_contacted_by ": { "id": "XXX" } ,
"note_updated_at": "2014-08-26T14:49:27-04:00" ,
"note": "Hello again!"
}
}
Updates and imports not involving emails failing due to email validation errors
I've just come across some unexpected behaviour.
When using the people update API to update a precinct_code, e.g. with the payload:
{'person': {'precinct_name': 'Burton Bradstock'}}
I received a "400 Bad Request" with the response
{"code":"validation_failed","message":"Validation Failed.","validation_errors":["email '[email protected]' should look like an email address"]}
The same thing happened with imports that didn't involve email addresses failing because of email validation errors.
submitted
Because of the need to replicate this issue and the need for sensitive data to do so, I'm reaching out via email.
Use NationBuilder as an SSO provider
Hi, We would like to make NationBuilder more central in our infrastructure. We would like to build on top of it. Is there a way to authenticate users in our Mobile App with NationBuilder. And I am not talking about authenticating the Admins. This is what OAuth2 is for. I would like to authenticate the users in our nation that are thousands. We would like to keep certain information in our NationBuilder. Information about the user membership. A custom field that says if this use has access to our venue or no. That's it. We would like to give our users (not the nation builder admins) but the nation itself a Mobile App. A mobile app that will read this custom field and say to the users (not the admins, but the users in the nation) if they have access to our venue. The issue is that if a user has a Mobile app on their phone there is no way for them to authenticate with nation builder. NationBuilder is not an SSO Provider and there is no API endpoint for an App to check the username and password of a user using the Mobile App. So we can build web/modile apps for the nation builder admins, but we can not build web/mobile apps for the nation builder users, those that are part of our nation. What am I missing? Help me understand how could we build web/mobile apps that allow us to authenticate the users in our nation (not the admins of the nationbuilder.com installation) with NationBuilder. Thanks.
User information is not updated same email (WordPress - API - NationBuilder)
We are not able to update existing user Account (user is registerred only with email address) with additional information (like First Name, Last Name, phone) that will be submitted later using the same email address...
We are inplemented custom form on WordPress website and already integrated with NationBuilder (API based). All new users, who submitted via our form are registerred in NationBuilder. BUT if user will send via form new personal info with the identical email as was registerred - NationBuilder will not update user info (error: user already exist). User's Password in NationBuilder was not created or edited (so do not think this is the issue).
We tried 2 variants http://apiexplorer.nationbuilder.com/nationbuilder#People , but both are failed.
See below.
Look forward to hearinf any comments.
Regards
---------
Variant 1
$dataBuilder = array (
'person' => array(
'email' => "[email protected]","last_name" => "Smith", "first_name" =>"Bob"
));
$token = '3b30b97feea94bf20c31f83eb787d7d86b8a373561925d5b007a6bb6b79848d0';
$url = add_query_arg(
array('access_token' => $token), 'https://beekeepersandbox.nationbuilder.com/api/v1/people/push'
);
$json_data = json_encode($dataBuilder);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_TIMEOUT, '10');
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authorization: $token", "Content-Type: application/json", "Accept: application/json"));
curl_setopt($ch, CURLOPT_POSTFIELDS, $json_data);
$result = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$content_type = curl_getinfo($ch, CURLINFO_CONTENT_TYPE);
if ($curl_error = curl_error($ch)) {
throw new Exception($curl_error, Exception::CURL_ERROR);
} else {
$json_decode = json_decode($result, true);
}
curl_close($ch);
$response = array(
'result' => (null === $json_decode) ? $result : $json_decode,
'code' => $http_code,
'content_type' => $content_type
);
We get empty result without errors.
Variant 2
$params = array(
'person' => array(
'email' => '[email protected]','home_address' => array('country' => 'Germany', 'zip' => '66666' ))
);
$header = array('Authorization:' => $token,'Content-Type:' => 'application/json', 'Accept:' => 'application/json');
$response = $client->fetch($baseApiUrl . '/api/v1/people/push?access_token=myaccesstoken', $params, 'PUT',$header);
print_r($response);
i get the following response
Array
(
[result] => Array
(
[code] => missing_parameters
[message] => Missing Parameters.
[parameters] => Array
(
[0] => person
)
[inner_error] => Array
(
[name] => Api::Error::MissingParameters
[message] => Missing parameters: person
)
)
[code] => 400
[content_type] => application/json
)
Using API in PHP for email sign up form; how to activate/verify email address?
I've got a script working nicely where a user visiting a WordPress site can fill out their name and email address, check the opt-in box, and sign up to a list on NationBuilder. But I can't seem to find any information on how to have NationBuilder send a verification email or double opt-in message to the new user to confirm that the email is valid and they do really truly want to be on this list. How would we go about this using the API?
Using Nationbuilders donation form on Wordpress
Hi I'm working on moving a Nationbuilder site over to Wordpress for the CMS. There is a request to keep the donation form the same, but it looks to me like this is not possible. I think I can use a Wordpress donations integration/plugin and after a donation is taken, send the information to the Nationbuilder API. Is it possible to use the nationbuilder donations for with Wordpress? Or is that a no go?
completed
There are several approaches to this:
- Use WP for the rest of the site and NB for the donation form. The way this would work is that when someone selects a 'donation' button on the WP site they will be redirected to the NB donation form to process the payment.
- Use WP for the entire site and build an application that can consume processed donation data from the payment processor and make a request to our donation API to create a record of the transaction.
- Redirect from the WP site to a payment processor that integrates with our donation API which will create the record in NationBuilder without you having to build an application as mentioned in (2) above.
Using OAuth2 access tokens with the People API
We are trying to use the http://nationbuilder.com/people_api with the Push endpoint to create new donors in the NationBuilder system from our external website. Basically when we process a new transaction we want to record the person in NationBuilder using the API. Obviously asking the donor to approve this action as part of the donation process is a pretty strange, so I'm a bit puzzled by the use of OAuth2 for this use case.
I have been following the documentation here to do the development: http://nationbuilder.com/api_quickstart
I've managed to get things working in PHP as per this guide: http://nationbuilder.com/php_quickstart
It seems we need to manually approve the application to get access in order to capture an access token which we can then use to post information to NationBuilder. Am I taking the right approach here? Should I be storing the access token server side to use later down the track for all our API requests? What happens when the access token expires?
submitted
Sebastian, the authorization is handled on a per-nation basis, so you won't need donors to approve passing their information once you have an access token from the nation. Per the quickstart guide, you'll have a nation administrator authorize the app, you'll get a short-live code back, then exchange if for an access token. That token should be stored securely and can be used again and again to pass information back to the appropriate nation. It expires only if revoked - then you'd need to have your app authorized again by the nation.
Using the API from "pure" Javascript
I'd like to call into the API from within some JavaScript code, purely running in the browser.
How can you authenticate safely if you want to use the API purely on a client side application? Many APIs allow you to restrict a token to a single or set of referrers (so they only work on sites under certain domains). Is there a similar mechanism within NationBuilder's API?
Using webhooks with PHP
Autumn Welles with Richir Outreach posted up this helpful NationBuilder webhooks + PHP tutorial with example script earlier this year.
Validation Error when Setting Membership Expiration Date to NULL
I'm attempting to use the new Membership API to update membership records. We have a class of members whose memberships do not expire, but whose membership records were erroneously given an expiration date.
When I use the API to update the membership expiration date to NULL, I throw a validation error.
PUT /people/:person_id/memberships
{
"membership" : {
"name" : "Standard"
, "status" : "active"
, "expires_on" : null
}
}
Any thoughts on how to fix? I'm considering just setting the expiration date 100 years in the future, but that could upset queries for members without expiration dates.
Webhhok support
I would like to run a PHP webhook from a 3rd party payment portal on a NationBuilder site. The payment is sent to the payment provider from the NationBuilder site and I would like to send custom emails when the payment is approved. I have already written and tested the script on my own server.
Is this possible on NationBuilder websites?
Webhooks are not firing
Webhooks don't seem to be firing for person created and changed webhooks. Possibly other events that trigger webhooks are also effected.
completed
This issue has been resolved.
Webhooks do not immediately trigger when adding a tag
When adding a tag to someone in your database, the 'person changed' webhook will not fire until you save that profile or a different profile in the database. This makes syncing tags with an external database a challenge.
Webhooks: how to comunicate success received
Sorry for the question, i'll receive a lot of equal webhook callback, Is there a way to prevent this ? i don't know, for example reply with an empy body with status code 200? thanks for help
Webhooks: Support for Events
Hello,
I'm suggesting support for webhooks for changes (creation, update, deletion) to events administered within NationBuilder.
My use case is I'm building a web app to index political events around the country. If groups, who are NationBuilder customers, could connect to it and submit new events and updates, that would have a huge impact on adoption, which would in turn impact event attendance for those customers, and subsequent volunteering, contributions and other engagement from the supporters. I can imagine other third party sites might be interested in this functionality too.
I'm a developer myself, so I'm happy to submit a pull request or sample code if that would be useful, but I'd be curious to hear NationBuilder's thoughts on adding this feature.
Thank you!
Jon
submitted
Jon,
Have you considered setting up your app so that customers can authenticate it against their nation and then you can use our events API to index events in any nation that authenticates on a rolling basis? It seems like that would be a work-around that would require as much, if not less, work on the part of the nation owner to setup.
What is the best way to fetch all field keys of people in a nation?
I have searched through the API docs and developer forum and do not see an endpoint for fetching a list of the keys in a nation. I would like to bring back all of the standard fields as well as the keys of any custom fields in the nation. The only route I see is to fetch a person and pull the keys from the response. I'm concerned this may not return all of the keys present in the nation if this one person has null values for some keys.
What kind of apps do NB clients need but do not have yet?
As a third-party app builder, I'm wondering what the NB staff hears about "apps NB customers wish they had."
I figure this is a good question to throw out there in the open, because many of the app developers on this list could benefit from hearing some advice about the unmet needs of current NB customers.
When Installing Field Edge app it disappears from my Control Panel
When I install Field Edge it doesn't appear in Installed Apps or in the app listing. This makes me concerned it's not installed.
submitted
We are investigating why FieldEdge doesn't show up under 'Installed Apps.' After testing the integration, it is clear that FieldEdge is syncing with the nation so functionality is not limited due to this issue.
When is it safe to delete list after invoking add tag endpoint?
I want to add/delete a bunch of tags from a bunch of people. This involves multiple sequences along the lines
- Create temporary list
- Add people to list
- Add tags to people in list / remove tags from people in list
- Delete list
The documentation for the add tag endpoint says:
Use this endpoint to apply a tag to the people contained in a list. Note: this endpoint returns a HTTP 204 status code, but the tag is not applied immediately. For larger lists, this operation takes many minutes.
The remove tags endpoint is similar. So when is it safe to delete the list?
completed
Andrew,
Once your done with adding/removing tags from those people you can delete the list. Deleting the list does not delete the people on that list (http://apiexplorer.nationbuilder.com/nationbuilder#Lists) when you hit the /api/v1/lists/:list ID endpoint.
When is it safe to delete list after invoking add tag endpoint?
I want to add/delete a bunch of tags from a bunch of people. This involves multiple sequences along the lines
- Create temporary list
- Add people to list
- Add tags to people in list / remove tags from people in list
- Delete list
The documentation for the add tag endpoint says:
Use this endpoint to apply a tag to the people contained in a list. Note: this endpoint returns a HTTP 204 status code, but the tag is not applied immediately. For larger lists, this operation takes many minutes.
The remove tags endpoint is similar. So when is it safe to delete the list?
duplicate
When POSTing to donation API I keep getting a 'slug can't be blank' error
We are trying to hit the following API
token.post('/api/v1/donations', headers: {"Content-Type"=>"application/json", "Accept"=>"application/json"}, body: {:donation=>{:donor_id=>1234, :amount_in_cents=>1000, :payment_type_name=>"Other", :tracking_code_slug=>"", :succeeded_at=>Wed, 07 Sep 2016 23:18:32 EDT -04:00}})
completed
The tracking_code_slug can't be blank. It needs the tracking code value as a string, a 'null' or just not including the resource in the request.
When will API and web hooks be updated to reflect the new paths?
What is the status on webhooks/api access to paths?
When will Nationbuilder Liquid support the hmac_sha256 filter?
Currently the only way I can find to have a nationbuilder theme make a secure API call is to hash some auth info about the current user in the template with a secret key. Shopify Liquid and most liquid variants support the hmac_sha256 filter (https://shopify.dev/docs/themes/liquid/reference/filters/string-filters#hmac_sha256) for this purpose, and have for several years. However, sadly this is not available in nationbuilder yet. The only hashing function available in nationbuilder liquid is md5, which is much less secure and isn't a hmac. When will nationbuilder liquid support his important hmac_sha256 filter? I think given how much nationbuilder's users are targets for hackers, it's absolutely essential for nationbuilder to support the hmac_sha256 liquid filter.
completed
We added the hmac_sha256 as well as sha256 and hmac_sha1 filters in November 2021. As of yesterday we also have hmac_sha512 available for liquid templates. Documentation can be found here.
zapier.com Integrations
Do you support integration using Zapier.com? This would be very helpful as it supports hundreds of different integrations in one package. Thanks!