Skip to main content

Making Nationbuilder API requests inside of a Nationbuilder Theme

I need to be able to make calls to the nationbuilder API inside of a nationbuilder theme on behalf of the current user. Is there a way to get an API token for the user inside of a template? I see there's _nbuild_token and _nbuild_session cookies, but those don't work as API access tokens. I don't see any liquid template variables that look like they would be useful in getting an access token for the current user. Alternatively, I can set up a REST server that can make calls to the nationbuilder API, and make requests to that from my template. However, I need some way to verify who the user is that's making that call. If I send the _nbuild_token and/or _nbuild_session from the cookies along with the REST request, is there some way to verify which user_id that token belongs to on the backend? I just need some way to validate that the user making the request is a logged-in user on my nationbuilder site so I know what they should or shouldn't have access to.

Official response from

It isn't possible to use the API token from within the website theme. You will need to run the requests separately as you suggest.
Regarding controlling the display, you will need to use our request variables in liquid conditionals to test whether the user should see the content.

Share this post

Showing 2 reactions

How would you tag this suggestion?
Please check your e-mail for a link to activate your account.