contacts

contacts.find

Returns the contacts that meet the given conditions.

JS
CR.api('commerce.contacts.find', request, function(response) { … });
HTTP
POST /open2b/api/v3/commerce.contacts.find

request

{
  "conditions" : { // returns the contacts of this …
    "customer" : 37091 // … customer (id) - int(1…)
  },
  "fields" : [ "id", "customer", … ], // fields to return - string
  "order" : [ "id" ], // sort order of returned contacts, can contain "id", "-id", "customer", "-customer", "name", "-name",
                      // "phone", "-phone", "email", "-email", "note" and "-note" - string
  "limit" : 10, // maximum number of contacts to return - int(1…100)
  "first": 0 // index of the first contact to return - int(0…)
}

response

{
  "status" : "ok",
  "contacts" : [ {
    "id" : 59068, // identifier - int(1…)
    "customer" : 37091, // customer (id) - int(1…)
    "name" : "John Smith", // name - string(1…50)
    "phone" : "", // phone number - string(0…15)
    "email" : "", // Email address - string(3…120)
    "note" : "" // note - string(0…255)
  }, … ]
}

contacts.get

Returns a contact given its identifier.

JS
CR.api('commerce.contacts.get', request, function(response) { … });
HTTP
POST /open2b/api/v3/commerce.contacts.get

request

{
  "id" : 59068, // identifier (required) - int(1…)
  "fields" : [ "id", "customer", … ] // fields to return - string
}

response

{
  "status" : "ok",
  "contact" : { // (can be null)
    "id" : 59068, // identifier - int(1…)
    "customer" : 37091, // customer (id) - int(1…)
    "name" : "John Smith", // name - string(1…50)
    "phone" : "", // phone number - string(0…15)
    "email" : "", // Email address - string(3…120)
    "note" : "" // note - string(0…255)
  }
}

contacts.count

Number of contacts that meet the given conditions.

JS
CR.api('commerce.contacts.count', request, function(response) { … });
HTTP
POST /open2b/api/v3/commerce.contacts.count

request

{
  "conditions" : { // counts the contacts of this … (can be null)
    "customer" : 37091 // … customer (id) - int(1…)
  }
}

response

{
  "status" : "ok",
  "count" : 67 // number of contacts - int(0…)
}

contacts.create

Create a new contact.

JS
CR.api('commerce.contacts.create', request, function(response) { … });
HTTP
POST /open2b/api/v3/commerce.contacts.create

request

{
  "contact" : { // contact to create (required)
    "customer" : 37091, // customer (id) (required) - int(1…)
    "name" : "John Smith", // name (required) - string(1…50)
    "phone" : "", // phone number - string(0…15)
    "email" : "", // Email address (can be null) - string(3…120)
    "note" : "" // note - string(0…255)
  }
}

response

{
  "status" : "ok",  
  "id" : 59068 // identifier of the new contact - int(1…)
}

Errors

Field Type Description
customer NotFound Customer <customer> does not exist
email InvalidValue '<email>' is not a well formed email address

contacts.update

Updates a contact. Any fields left out of the request will remain unchanged.

JS
CR.api('commerce.contacts.update', request, function(response) { … });
HTTP
POST /open2b/api/v3/commerce.contacts.update

request

{
  "id" : 59068, // identifier of the contact to update (required)
  "contact" : { // contact's fields to update (required)
    "customer" : 37091, // customer (id) - int(1…)
    "name" : "John Smith", // name - string(1…50)
    "phone" : "", // phone number - string(0…15)
    "email" : "", // Email address (can be null) - string(3…120)
    "note" : "" // note - string(0…255)
  }
}

response

{
  "status" : "ok"
}

Errors

Field Type Description
customer NotFound Customer <customer> does not exist
email InvalidValue '<email>' is not a well formed email address
id NotFound Contact <id> does not exist

contacts.delete

Deletes one or more contacts.

JS
CR.api('commerce.contacts.delete', request, function(response) { … });
HTTP
POST /open2b/api/v3/commerce.contacts.delete

request

{
  "ids" : [ 59068, 12078, 23939, … ] // identifiers of the contacts to delete (required) - int(1…)
}

response

{
  "status" : "ok"
}