API

If you ever need to add registrations or serial numbers programmatically, there is an API for it.

All endpoints are available at https://product-reg.varify.xyz/api/

Generate Access Token

Access token can be obtain in the Shopify Admin > Apps > My Product Registration > 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

  1. Make an HTTP POST request to the endpoint - https://product-reg.varify.xyz/api/registrations

  2. The POST request should have the following JSON payload

{
    "accessToken": "12323213123",
    "registrations": [
        {
            "productName": "MacBook 2018",
            "customerEmail": "tom@example.com",
            "customerName": "Tom Delong",
            "serialNumbers": [
                "123",
                "321"
            ],
            "purchaseDate": "2019-01-01",
            "greetings": "hello world!",
        }
    ]
}

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)

  1. Make a HTTP PUT request to the endpoint - https://product-reg.varify.xyz/api/registrations/:regId

  2. The PUT request should have the following JSON payload

{
    "accessToken": "12323213123",
    "registration": {
            "productName": "MacBook 2018",
            "customerEmail": "tom@example.com",
            "customerName": "Tom Delong",
            "serialNumbers": [
                "123",
                "321"
            ],
            "purchaseDate": "2019-01-01",
            "fields": {
                "greetings": "hello agaiin",
            }
    }
}

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

  1. make a HTTP DELETE request to the endpoint /api/registrations/:regId

  2. It will return 200 if its all good, otherwise throw error with message

Registrations (GET) - Get customer's registrations

  1. make a HTTP GET request to the endpoint /api/registrations?email=tom@example.com, the email must be in the query string

  2. 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

  • customerId - Only get registrations belong to specific customer id (shopify customer id) e.g /api/registrations?customerId=88888888

  • formSlug - Only get registration within specific form

  • limit - Limit the results

Serial Numbers

Here is example the payload for adding serial numbers (POST)

  1. Make a HTTP POST request to the endpoint /api/serial_numbers

  2. The POST request should have the following JSON payload

{
    "accessToken": "12323213123",
    "serialNumbers": [
        {
            "serialNumber": "22018",
            "sku": "mac123",
            "customerTags": "VIP,mac",
        }
    }

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

  1. Make a HTTP GET request to the endpoint /api/serial_number

  2. It will return a random unregistered serial number if there is one with status 200

  3. If there is no unregistered seiral number, it wil return 204

Get a serial number (GET)

Getting information of a serial number

  1. make a HTTP GET request to the endpoint /api/serial_numbers/test123, test123 is a serial number

  2. It will return the serial number info if there is one

  3. if there is no such serial number, it will return 204

Last updated