openapi: 3.1.2
info:
title: NationBuilder V2 Async Processes Donations API
version: '2.0'
description: 'The NationBuilder V2 API is a JSON:API-compliant API for managing NationBuilder
resources such as people, donations, events, and lists. It layers a few
conventions on top of the JSON:API standard, described below. For a broader
introduction, see the
[NationBuilder v2 API core concepts](https://support.nationbuilder.com/en/articles/9757369-nationbuilder-v2-api-core-concepts)
guide.
### Request and response format
Requests and responses follow the [JSON:API](https://jsonapi.org/) document
structure: single resources are returned under a top-level `data` member, and
collections are paginated arrays of resource objects with `links` for the
current, previous, and next pages. Related resources can be sideloaded into a
top-level `included` array with the `include` query parameter, and responses
can be trimmed to specific attributes with `fields[resource_type]` sparse
fieldsets (plus opt-in `extra_fields[resource_type]` attributes where noted).
Responses are served as `application/vnd.api+json`; request bodies may be
sent as `application/vnd.api+json` or `application/json`.
Filtering uses an operator syntax: `filter[attribute]=value` for
equality (comma-separated values act as OR), and
`filter[attribute][operator]=value` for other comparisons. String attributes
support `eq`, `not_eq`, `eql`, `not_eql`, `prefix`, `not_prefix`, `suffix`,
`not_suffix`, `match`, and `not_match`; numeric and date attributes support
`eq`, `not_eq`, `gt`, `gte`, `lt`, and `lte`. Note that JSON:API relationship
routes (`/resource/{id}/relationships/other`) are not provided; related
resources are reachable through the filtered index URLs given in each
resource''s `relationships` links.
### Errors
Error responses use a flat JSON body with a machine-readable `code` and a
human-readable `message`. Some errors carry additional detail members (for
example `validation_errors`). The exception is 422 validation failures,
which return a JSON:API `errors` array locating each invalid field via
`source.pointer`.
### Rate limiting
Requests are limited per access token (250 requests per 10-second window).
Every response includes `RateLimit-Limit`, `RateLimit-Remaining`, and
`RateLimit-Reset` headers; exceeding the limit returns a 429 with a
`Retry-After` header.
'
servers:
- url: https://{subdomain}.nationbuilder.com
variables:
subdomain:
default: yournation
description: Your NationBuilder nation slug
security:
- BearerAuth: []
tags:
- name: Donations
x-tag-expanded: false
description: 'Currently we allow you to record existing donation transactions via API V2. These transactions will not be backed by any kind of financial transaction.
See the [docs](https://support.nationbuilder.com/en/articles/2344242-create-or-record-an-individual-donation) for more information.
If associated with an existing signup, the first_name, middle_name, and last_name associated with the donation will be updated on the signup as well.
If the email is different than the primary email existing on the signup, it will be added to the signup''s email2, email3, or email4 instead.
'
paths:
/api/v2/donations:
parameters:
- $ref: '#/components/parameters/donation_index_include'
- $ref: '#/components/parameters/donation_sparse_fields'
- $ref: '#/components/parameters/donation_extra_fields'
post:
summary: Create a donation
tags:
- Donations
description: Creates a donation from given data
operationId: createDonation
responses:
'201':
description: The newly created donation.
headers:
RateLimit-Limit:
$ref: '#/components/headers/RateLimit-Limit'
RateLimit-Remaining:
$ref: '#/components/headers/RateLimit-Remaining'
RateLimit-Reset:
$ref: '#/components/headers/RateLimit-Reset'
content:
application/vnd.api+json:
schema:
$ref: '#/components/schemas/donation_show_response'
'400':
$ref: '#/components/responses/bad_request'
'401':
$ref: '#/components/responses/unauthorized'
'422':
$ref: '#/components/responses/unprocessable'
'429':
$ref: '#/components/responses/rate_limited'
requestBody:
$ref: '#/components/requestBodies/donation_create_request_body'
get:
summary: List all donations in a nation
tags:
- Donations
description: Lists all donations
operationId: listDonations
parameters:
- $ref: '#/components/parameters/pagination_number'
- $ref: '#/components/parameters/pagination_size'
responses:
'200':
description: A page of matching donations.
headers:
RateLimit-Limit:
$ref: '#/components/headers/RateLimit-Limit'
RateLimit-Remaining:
$ref: '#/components/headers/RateLimit-Remaining'
RateLimit-Reset:
$ref: '#/components/headers/RateLimit-Reset'
content:
application/vnd.api+json:
schema:
$ref: '#/components/schemas/donation_index_response'
'401':
$ref: '#/components/responses/unauthorized'
'429':
$ref: '#/components/responses/rate_limited'
/api/v2/donations/{id}:
parameters:
- $ref: '#/components/parameters/id'
- $ref: '#/components/parameters/donation_show_include'
- $ref: '#/components/parameters/donation_sparse_fields'
- $ref: '#/components/parameters/donation_extra_fields'
get:
summary: Show donation with provided ID
tags:
- Donations
description: Returns the donation that matches the given ID.
operationId: showDonation
responses:
'200':
description: The requested donation.
headers:
RateLimit-Limit:
$ref: '#/components/headers/RateLimit-Limit'
RateLimit-Remaining:
$ref: '#/components/headers/RateLimit-Remaining'
RateLimit-Reset:
$ref: '#/components/headers/RateLimit-Reset'
content:
application/vnd.api+json:
schema:
$ref: '#/components/schemas/donation_show_response'
'401':
$ref: '#/components/responses/unauthorized'
'404':
$ref: '#/components/responses/not_found'
'429':
$ref: '#/components/responses/rate_limited'
patch:
summary: Update an existing donation
tags:
- Donations
description: Updates an existing donation
operationId: updateDonation
responses:
'200':
description: The updated donation.
headers:
RateLimit-Limit:
$ref: '#/components/headers/RateLimit-Limit'
RateLimit-Remaining:
$ref: '#/components/headers/RateLimit-Remaining'
RateLimit-Reset:
$ref: '#/components/headers/RateLimit-Reset'
content:
application/vnd.api+json:
schema:
$ref: '#/components/schemas/donation_show_response'
'400':
$ref: '#/components/responses/bad_request'
'401':
$ref: '#/components/responses/unauthorized'
'404':
$ref: '#/components/responses/not_found'
'422':
$ref: '#/components/responses/unprocessable'
'429':
$ref: '#/components/responses/rate_limited'
requestBody:
$ref: '#/components/requestBodies/donation_update_request_body'
delete:
summary: Delete donation with provided ID
tags:
- Donations
description: Permanently removes the donation that matches the given ID.
operationId: deleteDonation
responses:
'200':
description: Confirmation that the donation was deleted.
headers:
RateLimit-Limit:
$ref: '#/components/headers/RateLimit-Limit'
RateLimit-Remaining:
$ref: '#/components/headers/RateLimit-Remaining'
RateLimit-Reset:
$ref: '#/components/headers/RateLimit-Reset'
content:
application/vnd.api+json:
schema:
$ref: '#/components/schemas/delete_document'
'401':
$ref: '#/components/responses/unauthorized'
'404':
$ref: '#/components/responses/not_found'
'429':
$ref: '#/components/responses/rate_limited'
components:
schemas:
error_response:
description: The error body returned for 4xx and 5xx responses, with a machine-readable code and a human-readable message. Some errors include additional detail members alongside these two. The exception is 422 validation failures, which are returned as JSON:API errors documents instead.
type: object
required:
- code
- message
properties:
code:
type: string
description: Machine-readable error code identifying the failure.
examples:
- not_found
message:
type: string
description: Human-readable explanation of the failure.
examples:
- Record not found
donation_sideload_values:
description: Relationship names that can be sideloaded with the include query parameter on donation endpoints.
type: string
enum:
- author
- donation_tracking_code
- import
- mailing
- membership
- page
- payment_type
- pledge
- recruiter
- signup
show_document:
description: The JSON:API top-level document shape for responses returning a single resource under the data member.
type: object
required:
- data
properties:
data:
type: object
description: The primary resource object; each resource binds its concrete schema here via allOf composition.
included:
$ref: '#/components/schemas/included'
meta:
type: object
description: Non-standard information about the document. Empty unless the endpoint has metadata to convey.
donation_read_only_attributes:
description: The read-only attributes of a donation.
type: object
properties:
amount:
type:
- string
- 'null'
examples:
- '5.00'
description: The order amount.
created_at:
type:
- string
- 'null'
format: date-time
examples:
- '2019-10-26T10:00:00-04:00'
import_id:
type:
- string
- 'null'
examples:
- '1'
description: The import that created this donation.
payout_id:
type:
- string
- 'null'
examples:
- po_abc123
description: The ID of the payout in which this NationBuilder Payments donation was included
status:
type:
- string
- 'null'
enum:
- succeeded
- pending
- failed
- canceled
- null
examples:
- succeeded
description: The status of the donation.
updated_at:
type:
- string
- 'null'
format: date-time
examples:
- '2019-10-26T10:00:00-04:00'
donation_index_response:
description: A paginated JSON:API response containing a list of donations.
allOf:
- $ref: '#/components/schemas/index_document'
- type: object
properties:
data:
type: array
items:
$ref: '#/components/schemas/donation_response_data'
donation_extra_field_values:
description: Opt-in donation attribute names requestable with extra_fields[donations].
type: string
enum:
- billing_address
- work_address
resource_identifier:
description: A JSON:API resource identifier object, the type/id pair that uniquely identifies a single resource.
type: object
required:
- type
- id
properties:
id:
type: string
description: Unique identifier of the resource.
examples:
- '1'
type:
type: string
description: The JSON:API resource type.
donation_response_data:
description: The JSON:API resource object representing a donation.
allOf:
- $ref: '#/components/schemas/resource_identifier'
- type: object
properties:
type:
const: donations
examples:
- donations
attributes:
allOf:
- $ref: '#/components/schemas/donation_read_write_attributes'
- $ref: '#/components/schemas/donation_read_only_attributes'
donation_show_response:
description: A JSON:API response containing a single donation.
allOf:
- $ref: '#/components/schemas/show_document'
- type: object
properties:
data:
$ref: '#/components/schemas/donation_response_data'
pagination_links:
description: JSON:API pagination links for the pages of a collection. A key whose page is unavailable, or that the server's pagination strategy does not provide, is omitted or null.
type: object
properties:
self:
type: string
description: Link to the current page.
examples:
- /articles?page[number]=2
first:
type:
- string
- 'null'
description: Link to the first page.
examples:
- /articles?page[number]=1
last:
type:
- string
- 'null'
description: Link to the last page.
examples:
- /articles?page[number]=5
prev:
type:
- string
- 'null'
description: Link to the previous page.
examples:
- /articles?page[number]=1
next:
type:
- string
- 'null'
description: Link to the next page.
examples:
- /articles?page[number]=3
index_document:
description: The JSON:API top-level document shape for paginated collection responses, with resource objects under data and pagination links.
type: object
required:
- data
properties:
data:
type: array
description: The page of resource objects for this collection; each resource binds its concrete item schema here via allOf composition.
links:
$ref: '#/components/schemas/pagination_links'
included:
$ref: '#/components/schemas/included'
meta:
type: object
description: Non-standard information about the document, such as requested statistics. Empty unless the endpoint has metadata to convey.
validation_error:
description: A single JSON:API error object describing a validation failure, locating the invalid field via source.pointer and carrying the model-level attribute, message, and code under meta.
type: object
properties:
code:
type: string
description: Machine-readable error code.
examples:
- unprocessable_entity
status:
type: string
description: The HTTP status code, as a string.
examples:
- '422'
title:
type: string
description: Short human-readable summary of the error type.
examples:
- Validation Error
detail:
type: string
description: Human-readable explanation specific to this failure.
examples:
- Email 'not-an-email' should look like an email address
source:
type: object
properties:
pointer:
type: string
description: JSON Pointer to the request document member the error relates to.
examples:
- /data/attributes/email
meta:
type: object
description: The underlying model validation error, including the attribute name, message, and code. Errors on sideposted resources nest these members under a relationship key.
properties:
attribute:
type: string
description: The attribute that failed validation.
message:
type: string
description: The validation failure message.
code:
type: string
description: The validation failure code.
delete_document:
examples:
- meta: {}
description: The successful destroy response, an empty JSON:API meta-only document returned with status 200 (rather than JSON:API's commonly used 204 No Content).
type: object
required:
- meta
additionalProperties: false
properties:
meta:
examples:
- {}
type: object
properties: {}
donation_update_request:
description: The request body for updating an existing donation.
allOf:
- $ref: '#/components/schemas/update_request_document'
- type: object
properties:
data:
type: object
properties:
id:
type: string
examples:
- '1'
type:
const: donations
examples:
- donations
attributes:
allOf:
- $ref: '#/components/schemas/donation_read_write_attributes'
- $ref: '#/components/schemas/donation_write_only_attributes'
rate_limited_response:
description: The body returned by the rate limiter when an access token exceeds its request quota.
type: object
required:
- message
properties:
message:
type: string
description: Human-readable explanation of the rate limit.
examples:
- You have made too many requests. Please try again later.
donation_field_values:
description: Readable donation attribute names selectable with sparse fieldsets (fields[donations]).
type: string
enum:
- actblue_order_number
- amount
- amount_in_cents
- canceled_at
- check_number
- created_at
- custom_values
- donation_tracking_code_id
- email
- employer
- failed_at
- first_name
- import_id
- is_corporate_contribution
- is_private
- last_name
- mailing_id
- membership_id
- middle_name
- note
- occupation
- page_id
- payment_type_id
- payment_type_name
- payout_id
- pending_at
- pledge_id
- signup_id
- status
- succeeded_at
- updated_at
donation_create_request:
description: The request body for creating a new donation.
allOf:
- $ref: '#/components/schemas/create_request_document'
- type: object
properties:
data:
type: object
properties:
type:
const: donations
examples:
- donations
attributes:
allOf:
- $ref: '#/components/schemas/donation_read_write_attributes'
- $ref: '#/components/schemas/donation_write_only_attributes'
donation_write_only_attributes:
description: The write-only attributes of a donation.
type: object
properties:
billing_address_attributes:
type:
- object
- 'null'
examples:
- address1: 20 W 34th St.
address2: Suite 100
address3: null
city: New York
state: NY
zip: '10001'
county: New York County
country_code: US
lat: '40.7484'
lng: '73.9857'
fips: '04'
submitted_address: 20 W 34th St. Suite 100, New York, NY 10001
distance: 0
import_id: '2'
work_phone: '5555555555'
phone_number: '5555555555'
phone_country_code: '1'
work_phone_number: '5555555555'
delete: true
description: " Attribute used to write data to the given donation's Billing address.\n When an address already exists, provided values will be used to patch the existing address data,\n only overwriting values provided in the payload.\n When no address exists, the existing data will be used to persist a new address.\n"
send_donor_receipt:
type:
- boolean
- 'null'
default: false
examples:
- false
work_address_attributes:
type:
- object
- 'null'
examples:
- address1: 20 W 34th St.
address2: Suite 100
address3: null
city: New York
state: NY
zip: '10001'
county: New York County
country_code: US
lat: '40.7484'
lng: '73.9857'
fips: '04'
submitted_address: 20 W 34th St. Suite 100, New York, NY 10001
distance: 0
import_id: '2'
work_phone: '5555555555'
phone_number: '5555555555'
phone_country_code: '1'
work_phone_number: '5555555555'
delete: true
description: " Attribute used to write data to the given donation's Work address.\n When an address already exists, provided values will be used to patch the existing address data,\n only overwriting values provided in the payload.\n When no address exists, the existing data will be used to persist a new address.\n"
validation_error_document:
description: The JSON:API errors document returned with status 422 when model validations fail on create or update. Unlike this API's flat 4xx error bodies, validation failures follow the JSON:API errors format.
type: object
required:
- errors
properties:
errors:
type: array
minItems: 1
items:
$ref: '#/components/schemas/validation_error'
update_request_document:
description: The JSON:API top-level document shape for update requests, whose data member identifies the resource by type and id and carries the changed attributes.
type: object
required:
- data
properties:
data:
type: object
required:
- type
- id
properties:
id:
type: string
description: The ID of the resource being updated.
type:
type: string
description: The JSON:API resource type of the resource being updated.
create_request_document:
description: The JSON:API top-level document shape for create requests, whose data member carries the new resource's type and attributes.
type: object
required:
- data
properties:
data:
type: object
required:
- type
properties:
type:
type: string
description: The JSON:API resource type of the resource being created.
resource:
description: A generic JSON:API resource object. Resources sideloaded in a document's included member use this shape; their attributes are those of the resource type named in the type member.
allOf:
- $ref: '#/components/schemas/resource_identifier'
- type: object
properties:
attributes:
type: object
description: The attributes of the resource, as documented for its resource type.
relationships:
type: object
description: References from this resource to other resources in the document.
included:
description: Sideloaded resources requested via the include query parameter. Each entry is a full resource object whose shape is documented under its own resource type.
type: array
items:
$ref: '#/components/schemas/resource'
donation_read_write_attributes:
description: The attributes of a donation that can be both read and written.
type: object
properties:
actblue_order_number:
type:
- string
- 'null'
examples:
- 123abc
description: The ActBlue order.
amount_in_cents:
type:
- integer
- 'null'
default: 0
examples:
- 500
description: The order amount in cents.
canceled_at:
type:
- string
- 'null'
format: date-time
examples:
- '2019-10-26T10:00:00-04:00'
description: When the order was canceled.
check_number:
type:
- string
- 'null'
examples:
- '1001'
description: Check number.
custom_values:
type:
- object
- 'null'
examples:
- custom_text: Text Value
custom_number: '22'
custom_checkbox: true
custom_multi: Some multiple choice option
description: Values for nation-defined fields on donation
donation_tracking_code_id:
type:
- string
- 'null'
examples:
- '1'
description: The associated donation tracking code.
email:
type:
- string
- 'null'
examples:
- donor@gmail.com
description: Donor's email.
employer:
type:
- string
- 'null'
examples:
- Wild Horse Co.
description: Donor's employer.
failed_at:
type:
- string
- 'null'
format: date-time
examples:
- '2019-10-26T10:00:00-04:00'
description: When the donation failed.
first_name:
type:
- string
- 'null'
examples:
- Lucy
description: Donor's first name.
is_corporate_contribution:
type:
- boolean
- 'null'
default: false
examples:
- false
description: Marks the donation as a corporate donation.
is_private:
type:
- boolean
- 'null'
default: false
examples:
- false
description: Marks the donation as private.
last_name:
type:
- string
- 'null'
examples:
- Butler
description: Donor's last name.
mailing_id:
type:
- string
- 'null'
examples:
- '1'
description: The mailing associated with this donation.
membership_id:
type:
- string
- 'null'
examples:
- '1'
description: The membership given from this donation.
middle_name:
type:
- string
- 'null'
examples:
- Octavia
description: Donor's middle name.
note:
type:
- string
- 'null'
examples:
- Dedicated to Lucy
description: Short description.
occupation:
type:
- string
- 'null'
examples:
- Postal Carrier
description: Donor's occupation.
page_id:
type:
- string
- 'null'
examples:
- '1'
description: The page associated with this donation.
payment_type_id:
type:
- string
- 'null'
examples:
- '1'
description: The payment type used.
payment_type_name:
type:
- string
- 'null'
examples:
- Cash
description: The name of the payment type
pending_at:
type:
- string
- 'null'
format: date-time
examples:
- '2019-10-26T10:00:00-04:00'
description: When the donation was marked as pending.
pledge_id:
type:
- string
- 'null'
examples:
- '1'
description: The associated pledge.
signup_id:
type:
- string
- 'null'
examples:
- '1'
description: The signup that donated.
succeeded_at:
type:
- string
- 'null'
format: date-time
examples:
- '2019-10-26T10:00:00-04:00'
description: When the donation succeeded.
parameters:
donation_sparse_fields:
name: fields[donations]
in: query
required: false
description: Comma-delimited list of donation attributes to only return in the response
schema:
type: array
default: []
uniqueItems: true
items:
$ref: '#/components/schemas/donation_field_values'
style: form
explode: false
pagination_size:
name: page[size]
description: 'Number of results to display per page (default: 20, max: 100, min: 1)'
in: query
required: false
schema:
type: string
default: '20'
id:
name: id
in: path
description: id
required: true
schema:
type: string
donation_extra_fields:
name: extra_fields[donations]
in: query
description: Comma-delimited list of extra donation attributes, which are only returned in the response if requested.
required: false
schema:
type: array
default: []
uniqueItems: true
items:
$ref: '#/components/schemas/donation_extra_field_values'
style: form
explode: false
donation_index_include:
name: include
in: query
description: 'Comma-delimited list of sideloaded resources to include as part of the donation index response.
See guidance [here](https://support.nationbuilder.com/en/articles/9899245-api-v2-walkthrough#h_2d5333adab) about
sideloading large numbers of resources and pagination.
'
schema:
type: array
default: []
uniqueItems: true
items:
$ref: '#/components/schemas/donation_sideload_values'
required: false
style: form
explode: false
donation_show_include:
name: include
in: query
description: 'Comma-delimited list of sideloaded resources to include as part of the donation response.
See guidance [here](https://support.nationbuilder.com/en/articles/9899245-api-v2-walkthrough#h_2d5333adab) about
sideloading large numbers of resources and pagination.
'
schema:
type: array
default: []
uniqueItems: true
items:
$ref: '#/components/schemas/donation_sideload_values'
required: false
style: form
explode: false
pagination_number:
name: page[number]
description: Page number to list (starting at 1)
in: query
required: false
schema:
type: string
default: '1'
headers:
RateLimit-Remaining:
description: Number of requests remaining for the current access token in the current rate-limit window.
schema:
type: string
examples:
- '249'
examples: {}
Retry-After:
description: Number of seconds to wait before retrying. Sent with 429 responses.
schema:
type: string
examples:
- '10'
examples: {}
RateLimit-Limit:
description: Maximum number of requests allowed for the current access token per rate-limit window (10 seconds).
schema:
type: string
examples:
- '250'
examples: {}
RateLimit
# --- truncated at 32 KB (36 KB total) ---
# Full source: https://raw.githubusercontent.com/api-evangelist/nationbuilder/refs/heads/main/openapi/nationbuilder-donations-api-openapi.yml