Create Address

Create a Address.

Parameters
  • dataformData, objectRequired

    Form Data needed when creating a new address.

    • typestringRequired

      Provide Address type. Current selection is only address.

    • attributesformData, objectRequired

      Attributes object with a few required fields.

      • namestringRequired

      • citystringRequired

      • country_codestringRequired

      • post_codestringRequired

      • streetstringRequired

      • street_numberstringRequired

      • address_linestring

      • notesstring

      • region_codestring

    • relationshipsformData, object

      Relationships object with order and user objects.

      • orderformData, object

        Add a relationships link between address and related Order.

        • typestring

        • idstring

          Related order id.

      • userformData, object

        Add a relationships link between address and related User.

        • typestring

        • idstring

          Related User id.

POST/api/v1/addresses

{
  const res = await fetch(`${BASE_URL}/api/v1/addresses`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    body: JSON.stringify(data)});

  const data = await res.json();
}

RESPONSE

{
  "data": {
    "id": "8cb768d9-e663-4d61-889b-ed204cb04914",
    "type": "addresses",
    "links": { "self": "/addresses/8cb768d9-e663-4d61-889b-ed204cb04914" },
    "attributes": {
      "address-line": null,
      "city": "Genève",
      "country": "Switzerland",
      "country-code": "CH",
      "name": "shipping_address",
      "notes": null,
      "post-code": "1207",
      "region": null,
      "region-code": null,
      "street": "Rue des Vollandes",
      "street-number": "58",
      "geolocation-lat": null,
      "geolocation-lng": null
    }
  }
}

Update Address

Update a Address

Parameters
  • idpath integerRequired

    Update a Address by specific Address id. You can retrieve this id from ...

  • dataformData, objectRequired

    Form Data needed when updating a new address.

    • idstringRequired

      Provide address id.

    • typestringRequired

      Provide address type. Current selection is only addresses.

    • attributesformData, objectRequired

      Attributes object with a few required fields.

      • address_linestring

      • citystring

      • country_codestring

      • namestring

      • notesstring

      • post_codestring

      • region_codestring

      • streetstring

      • street_numberstring

PATCH/api/v1/addresses/{id}

{
  const res = await fetch(`${BASE_URL}/api/v1/addresses/${id}`, {
    method: 'PATCH',
    headers: {
      'Content-Type': 'application/json'
    },
    body: JSON.stringify(data)});

  const data = await res.json();
}

RESPONSE

{
  "data": {
    "id": "8cb768d9-e663-4d61-889b-ed204cb04914",
    "type": "addresses",
    "links": {
      "self": "/addresses/8cb768d9-e663-4d61-889b-ed204cb04914"
    },
    "attributes": {
      "address-line": null,
      "city": "Genève",
      "country": "Switzerland",
      "country-code": "CH",
      "name": "shipping_address",
      "notes": "This is an address note",
      "post-code": "1207",
      "region": null,
      "region-code": null,
      "street": "Rue des Vollandes",
      "street-number": "58",
      "geolocation-lat": "46.2027289",
      "geolocation-lng": "6.162741"
    }
  }
}

Delete Address

Delete a Address.

Parameters
  • idpath integerRequired

    Delete a Address by specific Address id. You can retrieve this id from ...

DELETE/api/v1/addresses/{id}

{
  const res = await fetch(`${BASE_URL}/api/v1/addresses/${id}`, {
    method: 'DELETE',
    headers: {
      'Content-Type': 'application/json'
    }});
  const data = await res.json();
}