Start a new topic

Adding a new Customer Record

The Spire API can be used to create new customer records from data collected in an external application. A new customer record can be created by sending a POST request to the Spire customer API endpoint: 


https://[spire_host_name]:10880/api/v2/companies/[company_name]/customers


*Note: Replace both spire_host_name and company_name with the appropriate values for your Spire instance.*


When creating a new resource such as a customer via the API only a minimum amount of information is required. However most of the fields that are returned for a GET request to the customer endpoint can be optionally included with this POST request to set the customer properties as appropriate. 


If any fields in the examples do not make sense or apply in your scenario, please omit them in your request and default values will be applied


If the request is successful the server will return an HTTP response code of 201 with no content. 


The HTTP Location header of the response will then contain a link to the newly created resource which will contain the resource's id value.


Here are 3 examples that are valid JSON payloads that can be posted at the customer endpoint which will result in new customer records created assuming there is not a conflict with an already existing Customer No.


Minimal Information


{
    "customerNo":"ABOX-1",
    "name":"A Box"
}


More Information


{
    "customerNo":"ABOX-1",
    "name":"A Box",
    "status":"A",
    "applyFinanceCharges":true,
    "poRequired":false,
    "address":{
        "line1":"701 University Ave #-200",
        "line2":"",
        "line3":"",
        "line4":"",
        "city":"Sacramento",
        "postalCode":"95825",
        "provState":"CA",
        "country":"USA",
        "phone":{
            "number":"9169293501",
            "format":1
        },
        "fax":{
            "number":"",
            "format":1
        },
        "contacts":[
            {
                "name":"Alfreda Staffeld"
            },
            {
                "name":""
            },
            {
                "name":""
            }
        ],
        "shipCode":"",
        "shipDescription":"",
        "sellLevel":1,
        "email":"",
        "defaultWarehouse":"VA"
    }

}


Full Information


{
    "id": 1684,
    "code": "ABOX",
    "customerNo": "ABOX",
    "name": "A Box",
    "hold": false,
    "status": "A",
    "reference": "",
    "address": {
        "id": 1686,
        "type": "B",
        "linkTable": "CUST",
        "linkType": "CUST",
        "linkNo": "ABOX",
        "shipId": "",
        "name": "A Box",
        "line1": "701 University Ave #-200",
        "line2": "",
        "line3": "",
        "line4": "",
        "city": "Sacramento",
        "postalCode": "95825",
        "provState": "CA",
        "country": "USA",
        "phone": {
            "number": "9169293501",
            "format": 1
        },
        "fax": {
            "number": "",
            "format": 1
        },
        "email": "",
        "website": "",
        "shipCode": "",
        "shipDescription": "",
        "salesperson": {
            "code": "",
            "name": ""
        },
        "territory": {
            "code": "",
            "description": ""
        },
        "sellLevel": 1,
        "glAccount": "41100",
        "defaultWarehouse": "VA",
        "udf": {
            "notes": "",
            "value": "0",
            "lastcontact": "2021-04-06",
            "nextcontact": "2018-03-07",
            "salesstatus": ""
        },
        "contacts": [
            {
                "name": "Alfreda Staffeld",
                "email": "",
                "phone": {
                    "number": "",
                    "format": 1
                },
                "fax": {
                    "number": "",
                    "format": 1
                }
            },
            {
                "name": "",
                "email": "",
                "phone": {
                    "number": "",
                    "format": 1
                },
                "fax": {
                    "number": "",
                    "format": 1
                }
            },
            {
                "name": "",
                "email": "",
                "phone": {
                    "number": "",
                    "format": 1
                },
                "fax": {
                    "number": "",
                    "format": 1
                }
            }
        ],
        "salesTaxes": [
            {
                "code": 1,
                "exempt": ""
            },
            {
                "code": 2,
                "exempt": ""
            },
            {
                "code": 0,
                "exempt": ""
            },
            {
                "code": 0,
                "exempt": ""
            }
        ]
    },
    "shippingAddresses": [
        {
            "id": 4469,
            "type": "S",
            "linkTable": "CUST",
            "linkType": "CUST",
            "linkNo": "ABOX",
            "shipId": "SHIP TO STORE",
            "name": "Box Store",
            "line1": "123 Fake Street",
            "line2": "",
            "line3": "",
            "line4": "",
            "city": "Ogdenville",
            "postalCode": "A1A 1A1",
            "provState": "NL",
            "country": "CAN",
            "phone": {
                "number": null,
                "format": 1
            },
            "fax": {
                "number": null,
                "format": 1
            },
            "email": null,
            "website": null,
            "shipCode": "",
            "shipDescription": "",
            "salesperson": {
                "code": "",
                "name": ""
            },
            "territory": {
                "code": "",
                "description": ""
            },
            "sellLevel": 1,
            "glAccount": "41100",
            "defaultWarehouse": "VA",
            "udf": {
                "aa": "0"
            },
            "contacts": [
                {
                    "name": "John Cardboard",
                    "email": "president@a.box",
                    "phone": {
                        "number": "88888888881",
                        "format": 1
                    },
                    "fax": {
                        "number": "",
                        "format": 1
                    }
                },
                {
                    "name": "Jimmy Slick",
                    "email": "sales@a.box",
                    "phone": {
                        "number": "",
                        "format": 1
                    },
                    "fax": {
                        "number": "",
                        "format": 1
                    }
                },
                {
                    "name": "",
                    "email": "",
                    "phone": {
                        "number": "",
                        "format": 1
                    },
                    "fax": {
                        "number": "",
                        "format": 1
                    }
                }
            ],
            "salesTaxes": [
                {
                    "code": 1,
                    "exempt": ""
                },
                {
                    "code": 2,
                    "exempt": ""
                },
                {
                    "code": 0,
                    "exempt": ""
                },
                {
                    "code": 0,
                    "exempt": ""
                }
            ]
        }
    ],
    "paymentTerms": null,
    "applyFinanceCharges": true,
    "foregroundColor": 0,
    "backgroundColor": 16777215,
    "creditType": 0,
    "creditLimit": "0",
    "creditBalance": "44317.08",
    "creditApprovedBy": "SS",
    "creditApprovedDate": "2018-06-26",
    "currency": "",
    "userDef1": "",
    "userDef2": "",
    "discount": "0",
    "receivableAccount": "11210",
    "defaultShipTo": "",
    "specialCode": " ",
    "upload": false,
    "paymentProviderId": null,
    "udf": {
        "qqq": "0"
    }
}


json
(52 Bytes)
json
(902 Bytes)
json

1 person likes this idea
Login or Signup to post a comment