API
If you ever need to add registrations or serial numbers programmatically, there is an API for it.
All endpoints are available at https://api.productcares.com/api/
Generate Access Token
Access token can be obtain in the Admin > Settings > General > API Access token > Generate
Usage
Authentication
Requests to api endpoints needs an authentication header with the access token, setting the following in the request header e.g
Authorization: Bearer [access-token]
The access token can either put in the Authorization header or in the body, but put the access token in the header is preferred
Registrations - add new (POST)
Once the access token is generated, it can be use to register a new product
Make an HTTP POST request to the endpoint - https://api.productcares.com/api/registrations
The POST request should have the following JSON payload
It's possible to register multiple products in one call - simply add another registration object to the registrations array.
If need to add data to different form e.g not the default product-registration, a new key will needed add to the registration "type": "form-slug-name", then form slug name can be found in the Form > View on frontend
If there are extra fields just add those field as key within registration, the key name can be found in the form's design and field options
Registrations - Modify existing registration (PUT)
Once the access token is generated, it can be used to modify existing registration (the registration id can be found in the admin or via the webhook payload)
Make a HTTP PUT request to the endpoint - https://api.productcares.com/api/registrations/:regId
The PUT request should have the following JSON payload
If there are extra fields need to update, then put it under fields key
Delete registration (DELETE)
A registration id is needed to delete a registration
make a HTTP DELETE request to the endpoint /api/registrations/:regId
It will return 200 if its all good, otherwise throw error with message
Registrations (GET) - Get customer's registrations
make a HTTP GET request to the endpoint /api/registrations?email=tom@example.com, the email must be in the query string
It will return all customer's registrations
Available query strings
email - Only get registrations belong to specific email e.g /api/registrations?email=tom@example.com
formSlug - Only get registration within specific form
limit - Limit the results
Serial Numbers
Here is example the payload for adding serial numbers (POST)
Make a HTTP POST request to the endpoint /api/serial_numbers
The POST request should have the following JSON payload
The customerTags is a comma-separated of tags you want to tag the customer who register this serial number
Get a unused/unregistered serial number (GET)
You can get a random unregistered serial number
Make a HTTP GET request to the endpoint /api/serial_number
It will return a random unregistered serial number if there is one with status 200
If there is no unregistered seiral number, it wil return 204
Get a serial number (GET)
Getting information of a serial number
make a HTTP GET request to the endpoint /api/serial_numbers/test123, test123 is a serial number
It will return the serial number info if there is one
if there is no such serial number, it will return 204
Upload a file/asset/receipt
Its possible to upload a file and then use the URL as the receipt, the upload process is divided into two parts
Get a presigned URL from the app server
Here is the steps
Make a HTTP GET request to the endpoint /api/upload_fiile with the query string fileType, fileName and fileSize, e.g /api/upload_file?fileName=test.png&fileType=image/png&fileSize=123
Then it will return a signedRequest url which you can use it to upload file, the url is the final url of the file
Make a HTTP PUT request to the signedRequest url and put the file in the payload e.g
Here are some examples of how to upload it in Javascript
Last updated