Creating/Updating API Fundraisers
There are three ways to create and update fundraisers with our
fundraisers API: POST,
PATCH and PUT. This article explains the difference and which to use for
your application.
POST only creates new fundraisers. When using POST, specifying an ID
is optional. If an ID is not specified, one is generated for you and it is
up to you to save it in order to reference your fundraiser in the future.
If you specify an ID that has already been taken, the fundraiser will fail
to create and an error message will be returned.
PATCH only updates existing fundraisers. Specifying an ID is required to
use PATCH. If a fundraiser does not exist with the given ID, the request
will fail and return an error. PATCH will work with your IDs or
autogenerated ones. Only the parameters you send are updated; the rest keep
their current values.
PUT creates or updates a fundraiser with a given ID. If no fundraiser has the
ID, it creates one as POST does. If one does, it updates it as PATCH does,
so only the parameters you send change. PUT is idempotent: repeating the same
request gives the same result.
Use POST and PATCH for one-off creates and edits, when you want an error if
the fundraiser already exists, or doesn’t exist yet. Use PUT to keep
fundraisers in sync with your own system, without having to know whether each
one exists yet.
Clearing fields
Section titled “Clearing fields”When updating a fundraiser with PATCH or PUT, leaving a parameter out keeps
its current value. To clear goal, start_time or end_time, send it as
null.
Other fields can be changed but not cleared:
beneficiary: a fundraiser can’t be left without one. Sending it asnull, or with an emptytype, is refused with an error.donation_flow:nullis refused with an error.organizersandorganization_ids: an empty ornulllist is ignored.