Opportunity

An opportunity is used to track a potential sale with a customer such as a bid, deal or proposal. For a full description of the model, see the Opportunity model definition.

List opportunities

The collection of opportunities on the Capsule account.

GET
https://api.capsulecrm.com/api/v2/opportunities

Query Parameters

Name Type Description
since Date

If set then includes only entities that have been changed after this date. Must in be ISO8601 format

page Integer

The page of results to return. Default: 1

perPage Integer

Number of entities to return per page. Value must be between 1 and 100 Default: 50

embed Array of String

Can be used to specify extra entities to fully include in the result. If provided, should be a comma separated list of strings. Accepted values are tags, fields, party and milestone

Response

Returns HTTP status code 200. The body of the response will contain an object with a single property opportunity which is an array of opportunity objects. In the case of an invalid request, an error message will be returned, as described in the errors section.

HTTP/1.1 200
Link: <https://api.capsulecrm.com/api/v2/opportunities?page=4>; rel="next"
{
  "opportunities": [
      {
      "opportunity": {
        "id": 12,
        "updatedAt": "2015-10-29T12:55:12Z",
        "description": "Scope and design web site shopping cart",
        "owner": {
          "id": 6,
          "username": "scottspacey",
          "name": "Scott Spacey"
        },
        "party": {
          "id": 581,
          "pictureURL": "http://assets0.zestia.biz:11564/theme/default/images/person_avatar_70.png",
          "type": "organisation",
          "name": "Capsule"
        },
        "milestone": {
          "id": 14,
          "name": "Bid"
        },
        "value": {
          "amount": 500,
          "currency": "GBP"
        },
        "expectedCloseOn": "2015-10-31",
        "probability": 50,
        "durationBasis": "FIXED",
        "duration": null,
        "closedOn": null,
        "createdAt": "2015-10-29T12:55:12Z",
        "name": "Consulting"
      }
    },
    {...  another opportunity object ...},
    {...  another opportunity object ...},
    {...  another opportunity object ...}
  ]
}

Headers:

Name Type Description
Link String

Links to the next and previous pages, encoded as defined in RFC 5988

Show opportunity

Returns a specific opportunity.

GET
https://api.capsulecrm.com/api/v2/opportunities/{opportunityId}

Query Parameters

Name Type Description
embed Array of String

Can be used to specify extra entities to fully include in the result. If provided, should be a comma separated list of strings. Accepted values are tags, fields, party and milestone

Response

Returns HTTP status code 200. The body of the response will be an Opportunity object.

HTTP/1.1 200
{
  "opportunity": {
    "id": 83948362,
    "updatedAt": "2015-10-29T12:55:12Z",
    "description": "Scope and design web site shopping cart",
    "owner": {
      "id": 6,
      "username": "scottspacey",
      "name": "Scott Spacey"
    },
    "party": {
      "id": 581,
      "pictureURL": "http://assets0.zestia.biz:11564/theme/default/images/person_avatar_70.png",
      "type": "organisation",
      "name": "Capsule"
    },
    "milestone": {
      "id": 14,
      "name": "Bid"
    },
    "value": {
      "amount": 500,
      "currency": "GBP"
    },
    "expectedCloseOn": "2015-10-31",
    "probability": 50,
    "durationBasis": "FIXED",
    "duration": null,
    "closedOn": null,
    "createdAt": "2015-10-29T12:55:12Z",
    "name": "Consulting"
  }
}

Show multiple opportunities

Returns a list of opportunities, specified by the opportunityIds provided. The opportunityIds must be a comma separated list of integers and can contain, at most, 10 values.

GET
https://api.capsulecrm.com/api/v2/opportunities/{opportunityIds}

Query Parameters

Name Type Description
embed Array of String

Can be used to specify extra entities to fully include in the result. If provided, should be a comma separated list of strings. Accepted values are tags, fields, party and milestone

Response

Returns HTTP status code 200. The body of the response will be an array of opportunity objects. Will return status code 404 if at least one of the provided ids does not match an existing opportunity. In the case of an invalid request, an error message will be returned, as described in the errors section.

HTTP/1.1 200
{
  "opportunities": [
      {
      "opportunity": {
        "id": 12,
        "updatedAt": "2015-10-29T12:55:12Z",
        "description": "Scope and design web site shopping cart",
        "owner": {
          "id": 6,
          "username": "scottspacey",
          "name": "Scott Spacey"
        },
        "party": {
          "id": 581,
          "pictureURL": "http://assets0.zestia.biz:11564/theme/default/images/person_avatar_70.png",
          "type": "organisation",
          "name": "Capsule"
        },
        "milestone": {
          "id": 14,
          "name": "Bid"
        },
        "value": {
          "amount": 500,
          "currency": "GBP"
        },
        "expectedCloseOn": "2015-10-31",
        "probability": 50,
        "durationBasis": "FIXED",
        "duration": null,
        "closedOn": null,
        "createdAt": "2015-10-29T12:55:12Z",
        "name": "Consulting"
      }
    },
    {...  another opportunity object ...},
    {...  another opportunity object ...},
    {...  another opportunity object ...}
  ]
}

Create opportunity

Creates a new opportunity. The body must contain an object with a single property opportunity which must be an Opportunity object.

POST
https://api.capsulecrm.com/api/v2/opportunities
          {
  "opportunity": {
    "description": "Scope and design web site shopping cart",
    "party": {
      "id": 581
    },
    "milestone": {
      "id": 14
    },
    "value": {
      "amount": 500,
      "currency": "GBP"
    },
    "expectedCloseOn": "2015-10-31",
    "probability": 50,
    "durationBasis": "FIXED",
    "name": "Consulting"
  }
}
        

Query Parameters

Name Type Description
embed Array of String

Can be used to specify extra entities to fully include in the result. If provided, should be a comma separated list of strings. Accepted values are tags, fields, party and milestone

Response

Returns HTTP status code 201. The body of the response will contain the opportunity as it was stored in Capsule.

HTTP/1.1 201
Location: https://api.capsulecrm.com/api/v2/opportunities/83948362
{
  "opportunity": {
    "id": 83948362,
    "updatedAt": "2015-10-29T12:55:12Z",
    "description": "Scope and design web site shopping cart",
    "owner": {
      "id": 6,
      "username": "scottspacey",
      "name": "Scott Spacey"
    },
    "party": {
      "id": 581,
      "pictureURL": "http://assets0.zestia.biz:11564/theme/default/images/person_avatar_70.png",
      "type": "organisation",
      "name": "Capsule"
    },
    "milestone": {
      "id": 14,
      "name": "Bid"
    },
    "value": {
      "amount": 500,
      "currency": "GBP"
    },
    "expectedCloseOn": "2015-10-31",
    "probability": 50,
    "durationBasis": "FIXED",
    "duration": null,
    "closedOn": null,
    "createdAt": "2015-10-29T12:55:12Z",
    "name": "Consulting"
  }
}

Headers:

Name Type Description
Location String

The URL that identifies the new opportunity

Update opportunity

Updates an existing opportunity. The body must contain an object with a single property opportunity which must be an Opportunity object. Fields that are not included in the request will remain unchanged.

To apply changes to entities in the tags or fields collections you can do the following:

  • updating an existing entity include the id and any attributes that are being updated
  • deleting an existing entity include the id and the following JSON attribute "_delete": true
  • adding a new entity create entity without an id

PUT
https://api.capsulecrm.com/api/v2/opportunities/{opportunityId}

Query Parameters

Name Type Description
embed Array of String

Can be used to specify extra entities to fully include in the result. If provided, should be a comma separated list of strings. Accepted values are tags, fields, party and milestone

Response

Returns HTTP status code 200. All good

HTTP/1.1 200
{
  "opportunity": {
    "id": 83948362,
    "updatedAt": "2015-10-29T12:55:12Z",
    "description": "Scope and design web site shopping cart",
    "owner": {
      "id": 6,
      "username": "scottspacey",
      "name": "Scott Spacey"
    },
    "party": {
      "id": 581,
      "pictureURL": "http://assets0.zestia.biz:11564/theme/default/images/person_avatar_70.png",
      "type": "organisation",
      "name": "Capsule"
    },
    "milestone": {
      "id": 14,
      "name": "Bid"
    },
    "value": {
      "amount": 500,
      "currency": "GBP"
    },
    "expectedCloseOn": "2015-10-31",
    "probability": 50,
    "durationBasis": "FIXED",
    "duration": null,
    "closedOn": null,
    "createdAt": "2015-10-29T12:55:12Z",
    "name": "Consulting"
  }
}

Delete opportunity

Fully delete a specific opportunity from capsule.

DELETE
https://api.capsulecrm.com/api/v2/opportunities/{opportunityId}

Response

Returns HTTP status code 204. Returns status code 204 with an empty body if the opportunity was successfully deleted.

HTTP/1.1 204

List deleted opportunities

Returns a collection of deleted opportunities on the Capsule account.

GET
https://api.capsulecrm.com/api/v2/opportunities/deleted

Query Parameters

Name Type Description
since Date

If set then includes only entities that have been changed after this date. Must in be ISO8601 format

Response

Returns HTTP status code 200. The body of the response will be an array of deleted opportunity objects. In the case of an invalid request, an error message will be returned, as described in the errors section.

HTTP/1.1 200
{
  "opportunities" : [ {
    "id" : 448354,
    "deletedAt" : "2015-07-14T11:26:19Z"
  }, {
    "id" : 448371,
    "deletedAt" : "2015-08-03T10:23:20Z"
  }, {
    "id" : 448426,
    "deletedAt" : "2015-08-03T11:10:25Z"
  } ]
}

Search opportunities

Search for opportunities on the Capsule account. This will return the same results as the global search inside Capsule.

If you’re looking for a more structured search (like filtering by Tag) we don’t currently have these endpoints documented however they are on the way - if you would like early access please contact us at support@capsulecrm.com.

GET
https://api.capsulecrm.com/api/v2/opportunities/search

Query Parameters

Name Type Description
q String

The value to search for e.g. a name, a postcode or a phone number.

page Integer

The page of results to return. Default: 1

perPage Integer

Number of entities to return per page. Value must be between 1 and 100 Default: 50

Response

Returns HTTP status code 200. The body of the response will contain an object with a single property opportunities which is an array of opportunity objects. In the case of an invalid request, an error message will be returned, as described in the errors section.

HTTP/1.1 200
Link: <https://api.capsulecrm.com/api/v2/opportunities/search?q=design&page=4>; rel="next"
{
  "opportunities": [
      {
      "opportunity": {
        "id": 12,
        "updatedAt": "2015-10-29T12:55:12Z",
        "description": "Scope and design web site shopping cart",
        "owner": {
          "id": 6,
          "username": "scottspacey",
          "name": "Scott Spacey"
        },
        "party": {
          "id": 581,
          "pictureURL": "http://assets0.zestia.biz:11564/theme/default/images/person_avatar_70.png",
          "type": "organisation",
          "name": "Capsule"
        },
        "milestone": {
          "id": 14,
          "name": "Bid"
        },
        "value": {
          "amount": 500,
          "currency": "GBP"
        },
        "expectedCloseOn": "2015-10-31",
        "probability": 50,
        "durationBasis": "FIXED",
        "duration": null,
        "closedOn": null,
        "createdAt": "2015-10-29T12:55:12Z",
        "name": "Consulting"
      }
    },
    {...  another opportunity object ...},
    {...  another opportunity object ...},
    {...  another opportunity object ...}
  ]
}

Headers:

Name Type Description
Link String

Links to the next and previous pages, encoded as defined in RFC 5988

List additional parties

The collection of additional parties related to this opportunity.

GET
https://api.capsulecrm.com/api/v2/opportunities/{opportunityId}/parties

Query Parameters

Name Type Description
page Integer

The page of results to return. Default: 1

perPage Integer

Number of entities to return per page. Value must be between 1 and 100 Default: 50

embed Array of String

Can be used to specify extra entities to fully include in the result. If provided, should be a comma separated list of strings. Accepted values are tags, fields and organisation

Response

Returns HTTP status code 200. The body of the response will contain an object with a single property parties which is an array of Party objects.

HTTP/1.1 200
Link: <https://api.capsulecrm.com/api/v2/opportunities/1/parties?page=4>; rel="next"
{
  "parties": [
    {
      "id": 11587,
      "type": "person",
      "about": null,
      "title": null,
      "firstName": "Scott",
      "lastName": "Spacey",
      "jobTitle": "Creative Director",
      "createdAt": "2015-09-15T10:43:23Z",
      "updatedAt": "2015-09-15T10:43:23Z",
      "organisation": null,
      "lastContactedAt": null,
      "addresses": [
        {
          "id": 12135,
          "type": null,
          "city": "Chicago",
          "country": "United States",
          "street": "847 North Rush Street",
          "state": "IL",
          "zip": "65629"
        }
      ],
      "phoneNumbers": [
        {
          "id": 12133,
          "type": null,
          "number": "773-338-7786"
        }
      ],
      "websites": [],
      "emailAddresses": [
        {
          "id": 12134,
          "type": "Work",
          "address": "scott@homestyleshop.co"
        }
      ],
      "pictureURL": "http://assets0.zestia.biz:11564/theme/default/images/person_avatar_70.png"
    }
  ]
}

Headers:

Name Type Description
Link String

Links to the next and previous pages, encoded as defined in RFC 5988

Add additional party

Add an person or organisation as an additional contact to the opportunity

POST
https://api.capsulecrm.com/api/v2/opportunities/{opportunityId}/parties/{partyId}

Response

Returns HTTP status code 204. Returns status code 204 with an empty body if the related contact was successfully added.

HTTP/1.1 204

Remove additional party

Remove that person or organisation as an additional contact of the opportunity

DELETE
https://api.capsulecrm.com/api/v2/opportunities/{opportunityId}/parties/{partyId}

Response

Returns HTTP status code 204. Returns status code 204 with an empty body if the related contact was successfully deleted.

HTTP/1.1 204