Customers

Beta Release

Index

List customers

get
Query parameters
enterprise_idstringOptional
Responses
200
Customers list
application/json
get
GET /v1/customers HTTP/1.1
Host: api
Accept: */*
200

Customers list

{
  "data": [
    {
      "id": "1",
      "type": "customer",
      "attributes": {
        "id": 1,
        "enterprise_id": 2,
        "first_name": "Alice",
        "last_name": "Springs",
        "code": "BUYER1",
        "email": "alice@example.com",
        "allow_charges": false,
        "tags": [
          "staff",
          "discount"
        ],
        "terms_and_conditions_accepted_at": "2022-03-12T15:55:00.000+11:00",
        "billing_address": null,
        "shipping_address": {
          "phone": "0404 333 222 111",
          "latitude": -37.8173751,
          "longitude": 144.964803195704,
          "first_name": "Alice",
          "last_name": "Springs",
          "street_address_1": "1 Flinders Street",
          "street_address_2": "",
          "postal_code": "1234",
          "locality": "Melbourne",
          "region": {
            "code": "Vic",
            "name": "Victoria"
          },
          "country": {
            "code": "AU",
            "name": "Australia"
          }
        }
      },
      "relationships": {
        "enterprise": {
          "data": {
            "id": "text",
            "type": "enterprise"
          },
          "links": {
            "related": "text"
          }
        }
      }
    }
  ],
  "meta": {
    "pagination": {
      "results": 250,
      "pages": 5,
      "page": 2,
      "per_page": 50
    }
  },
  "links": {
    "self": "text",
    "first": "text",
    "prev": "text",
    "next": "text",
    "last": "text"
  }
}

Code Examples

https://INSTANCE_URL/api/v1/customers
https://INSTANCE_URL/api/v1/customers?enterprise_id=ENTERPRISE_ID

Show

Show customer

get
Path parameters
idstringRequired
Responses
200
Customer
application/json
get
GET /v1/customers/{id} HTTP/1.1
Host: api
Accept: */*
{
  "data": {
    "id": "1",
    "type": "customer",
    "attributes": {
      "id": 1,
      "enterprise_id": 2,
      "first_name": "Alice",
      "last_name": "Springs",
      "code": "BUYER1",
      "email": "alice@example.com",
      "allow_charges": false,
      "tags": [
        "staff",
        "discount"
      ],
      "terms_and_conditions_accepted_at": "2022-03-12T15:55:00.000+11:00",
      "billing_address": null,
      "shipping_address": {
        "phone": "0404 333 222 111",
        "latitude": -37.8173751,
        "longitude": 144.964803195704,
        "first_name": "Alice",
        "last_name": "Springs",
        "street_address_1": "1 Flinders Street",
        "street_address_2": "",
        "postal_code": "1234",
        "locality": "Melbourne",
        "region": {
          "code": "Vic",
          "name": "Victoria"
        },
        "country": {
          "code": "AU",
          "name": "Australia"
        }
      }
    },
    "relationships": {
      "enterprise": {
        "data": {
          "id": "text",
          "type": "enterprise"
        },
        "links": {
          "related": "text"
        }
      }
    }
  },
  "meta": {},
  "links": {}
}

Code Examples

Create

Create customer

post
Body
enterprise_idintegerRequiredExample: 2
first_namestring | nullableOptionalExample: Alice
last_namestring | nullableOptionalExample: Springs
codestring | nullableOptionalExample: BUYER1
emailstringRequiredExample: alice@example.com
tagsstring[]OptionalExample: ["staff","discount"]
billing_addressobject | nullableOptional
shipping_addressobject | nullableOptionalExample: {"phone":"0404 333 222 111","latitude":-37.8173751,"longitude":144.964803195704,"first_name":"Alice","last_name":"Springs","street_address_1":"1 Flinders Street","street_address_2":"","postal_code":"1234","locality":"Melbourne","region":{"code":"Vic","name":"Victoria"},"country":{"code":"AU","name":"Australia"}}
Responses
201
Example customer created
application/json
post
POST /v1/customers HTTP/1.1
Host: api
Content-Type: application/json
Accept: */*
Content-Length: 490

{
  "enterprise_id": 2,
  "first_name": "Alice",
  "last_name": "Springs",
  "code": "BUYER1",
  "email": "alice@example.com",
  "tags": [
    "staff",
    "discount"
  ],
  "billing_address": null,
  "shipping_address": {
    "phone": "0404 333 222 111",
    "latitude": -37.8173751,
    "longitude": 144.964803195704,
    "first_name": "Alice",
    "last_name": "Springs",
    "street_address_1": "1 Flinders Street",
    "street_address_2": "",
    "postal_code": "1234",
    "locality": "Melbourne",
    "region": {
      "code": "Vic",
      "name": "Victoria"
    },
    "country": {
      "code": "AU",
      "name": "Australia"
    }
  }
}
{
  "data": {
    "id": "1",
    "type": "customer",
    "attributes": {
      "id": 1,
      "enterprise_id": 2,
      "first_name": "Alice",
      "last_name": "Springs",
      "code": "BUYER1",
      "email": "alice@example.com",
      "allow_charges": false,
      "tags": [
        "staff",
        "discount"
      ],
      "terms_and_conditions_accepted_at": "2022-03-12T15:55:00.000+11:00",
      "billing_address": null,
      "shipping_address": {
        "phone": "0404 333 222 111",
        "latitude": -37.8173751,
        "longitude": 144.964803195704,
        "first_name": "Alice",
        "last_name": "Springs",
        "street_address_1": "1 Flinders Street",
        "street_address_2": "",
        "postal_code": "1234",
        "locality": "Melbourne",
        "region": {
          "code": "Vic",
          "name": "Victoria"
        },
        "country": {
          "code": "AU",
          "name": "Australia"
        }
      }
    },
    "relationships": {
      "enterprise": {
        "data": {
          "id": "text",
          "type": "enterprise"
        },
        "links": {
          "related": "text"
        }
      }
    }
  },
  "meta": {},
  "links": {}
}

Code Examples

curl -X POST "INSTANCE_URL/api/v1/customers" 
     -H "X-Spree-Token: YOUR_API_KEY" 
     -H "accept: application/json"
     -d "enterprise_id: ENTERPRISE_ID"
     -d "email: EMAIL"
     -d "first_name: FIRST_NAME"
     -d "last_name: LAST_NAME"
     -d "tags: TAG_LIST" 

Update

Update customer

put
Path parameters
idstringRequired
Body
enterprise_idintegerRequiredExample: 2
first_namestring | nullableOptionalExample: Alice
last_namestring | nullableOptionalExample: Springs
codestring | nullableOptionalExample: BUYER1
emailstringRequiredExample: alice@example.com
tagsstring[]OptionalExample: ["staff","discount"]
billing_addressobject | nullableOptional
shipping_addressobject | nullableOptionalExample: {"phone":"0404 333 222 111","latitude":-37.8173751,"longitude":144.964803195704,"first_name":"Alice","last_name":"Springs","street_address_1":"1 Flinders Street","street_address_2":"","postal_code":"1234","locality":"Melbourne","region":{"code":"Vic","name":"Victoria"},"country":{"code":"AU","name":"Australia"}}
Responses
200
Customer updated
application/json
put
PUT /v1/customers/{id} HTTP/1.1
Host: api
Content-Type: application/json
Accept: */*
Content-Length: 490

{
  "enterprise_id": 2,
  "first_name": "Alice",
  "last_name": "Springs",
  "code": "BUYER1",
  "email": "alice@example.com",
  "tags": [
    "staff",
    "discount"
  ],
  "billing_address": null,
  "shipping_address": {
    "phone": "0404 333 222 111",
    "latitude": -37.8173751,
    "longitude": 144.964803195704,
    "first_name": "Alice",
    "last_name": "Springs",
    "street_address_1": "1 Flinders Street",
    "street_address_2": "",
    "postal_code": "1234",
    "locality": "Melbourne",
    "region": {
      "code": "Vic",
      "name": "Victoria"
    },
    "country": {
      "code": "AU",
      "name": "Australia"
    }
  }
}
{
  "data": {
    "id": "1",
    "type": "customer",
    "attributes": {
      "id": 1,
      "enterprise_id": 2,
      "first_name": "Alice",
      "last_name": "Springs",
      "code": "BUYER1",
      "email": "alice@example.com",
      "allow_charges": false,
      "tags": [
        "staff",
        "discount"
      ],
      "terms_and_conditions_accepted_at": "2022-03-12T15:55:00.000+11:00",
      "billing_address": null,
      "shipping_address": {
        "phone": "0404 333 222 111",
        "latitude": -37.8173751,
        "longitude": 144.964803195704,
        "first_name": "Alice",
        "last_name": "Springs",
        "street_address_1": "1 Flinders Street",
        "street_address_2": "",
        "postal_code": "1234",
        "locality": "Melbourne",
        "region": {
          "code": "Vic",
          "name": "Victoria"
        },
        "country": {
          "code": "AU",
          "name": "Australia"
        }
      }
    },
    "relationships": {
      "enterprise": {
        "data": {
          "id": "text",
          "type": "enterprise"
        },
        "links": {
          "related": "text"
        }
      }
    }
  },
  "meta": {},
  "links": {}
}

Destroy

Delete customer

delete
Path parameters
idstringRequired
Responses
200
Customer deleted
application/json
delete
DELETE /v1/customers/{id} HTTP/1.1
Host: api
Accept: */*
200

Customer deleted

{
  "data": {
    "id": "1",
    "type": "customer",
    "attributes": {
      "id": 1,
      "enterprise_id": 2,
      "first_name": "Alice",
      "last_name": "Springs",
      "code": "BUYER1",
      "email": "alice@example.com",
      "allow_charges": false,
      "tags": [
        "staff",
        "discount"
      ],
      "terms_and_conditions_accepted_at": "2022-03-12T15:55:00.000+11:00",
      "billing_address": null,
      "shipping_address": {
        "phone": "0404 333 222 111",
        "latitude": -37.8173751,
        "longitude": 144.964803195704,
        "first_name": "Alice",
        "last_name": "Springs",
        "street_address_1": "1 Flinders Street",
        "street_address_2": "",
        "postal_code": "1234",
        "locality": "Melbourne",
        "region": {
          "code": "Vic",
          "name": "Victoria"
        },
        "country": {
          "code": "AU",
          "name": "Australia"
        }
      }
    },
    "relationships": {
      "enterprise": {
        "data": {
          "id": "text",
          "type": "enterprise"
        },
        "links": {
          "related": "text"
        }
      }
    }
  },
  "meta": {},
  "links": {}
}

Code Examples

Last updated