Skip to main content
All CollectionsAPI
Generating API Tokens
Generating API Tokens

Use the latest API to give your application access to NationBuilder's core features

Updated over a week ago

Access Tokens

To interact with the NationBuilder API v2, you need a refreshing API token. This token is essential for authenticating your requests and accessing the API’s resources.

Generating a Test Token:

  1. Navigate to the NationBuilder control panel.

  2. Go to Settings > Developer > API token.

  3. Generate a test token. Note that this token will expire in 24 hours.

For production use, you will need to generate tokens via the OAuth flow. For more information, refer to the migration guide.

Example:

curl -H "Authorization: Bearer YOUR_ACCESS_TOKEN" https://api.nationbuilder.com/v2/your_endpoint

Refreshing Tokens

OAuth tokens typically have an expiration time, after which they need to be refreshed. To refresh your token, you will use the refresh token obtained during the initial authentication process.

  1. Send a POST request to the token endpoint with the refresh token.

  2. Retrieve the new access token from the response.

Example:

POST /oauth/token Host: www.nationbuilder.com Content-Type: application/json { "grant_type": "refresh_token", "refresh_token": "YOUR_REFRESH_TOKEN", "client_id": "YOUR_CLIENT_ID", "client_secret": "YOUR_CLIENT_SECRET" }
Did this answer your question?