Creating/Updating API Fundraisers
There are two patterns you can utilize in our
fundraisers API — creating
via POST
and updating via PATCH
or what we call placing via PUT
. This
article will explain the difference and give you an idea of which you should use
for your application.
POST
only creates new fundraisers. When using POST
, specifying an ID
is optional. If an ID is not spcified, 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. PATCH
will accept partial updates where only the
attributes that are specified will be updated.
PUT
can create new fundraisers or overwrite existing ones. Specifying an
ID is required to use PUT
and is idempotent, so unless there is an error
in your data, it should always work. If a fundraiser exists with the given
ID, it will be overwritten. If it does not, it will be created. PUT
will
work with your IDs or autogenerated ones. Important: parameters sent
to PUT must be complete. Unlike PATCH
, partial updates will reset all
unspecified attributes for the fundraiser.
Use POST
and PATCH
if you want to be specific when creating or
updating fundraisers and want to get an error message when trying to
overwrite existing fundraisers or update non-existant fundraisers. Use
PUT
if you don’t care about overwriting existing fundraisers and want
guarenteed success with valid parameters.