Release Management
This page describes the APIs Onshape provides for working with revisions and part numbers.
Prerequisites
|
---|
Examples
Get the next available part number
Endpoint
Query Params
{
"cid": "{cid}",
"did": "{did}"
}
You must provide either the company ID or the ID of a document owned by the company.
Request Body
{
"itemPartNumbers": [
{
"documentId": "{did}",
"elementId": "{eid}",
"elementType": 0,
"numberSchemeResourceTypeId": "8c96700620f77935a0b2cddc",
"partId": "{partId}",
"partNumber": "{partNumber}",
"workspaceId": "{wid}"
}
]
}
See the API Explorer for a full list for allowed values and additional parameter options.
Example
- Call findCompany to get your company ID.
- Use
id
from the response (NOTaddress.id
orownerId
) as thecid
in Step 3.
- Use
- Call getPartsWMV or getPartsWMVE to get the part’s
partNumber
andpartId
. - Call updateNextNumbers:
curl -X 'POST' \ 'https://{baseUrl}.onshape.com/api/v10/partnumber/nextnumbers?cid={cid}' \ -H 'Accept: application/json;charset=UTF-8; qs=0.09' \ -H 'Authorization: Basic {credentials}' \ -H 'Content-Type: application/json;charset=UTF-8; qs=0.09' \ -d '{ "itemPartNumbers": [ { "documentId": "{did}", "elementId": "{eid}", "elementType": 0, "numberSchemeResourceTypeId": "8c96700620f77935a0b2cddc", "partId": "{partId}", "partNumber": "{partNumber}", "workspaceId": "{wid}" } ] }'
import requests import json auth = (access_key, secret_key) # See Authentication guide headers = { 'Accept': 'application/json;charset=UTF-8;qs=0.09', 'Content-Type': 'application/json;charset=UTF-8; qs=0.09' } api_url = "https://{baseUrl}.onshape.com/api/v10/partnumber/nextnumbers" queryParams = { "cid": "{cid}" } body = { "itemPartNumbers": [ { "documentId": "{did}", "elementId": "{eid}", "elementType": 0, "numberSchemeResourceTypeId": "8c96700620f77935a0b2cddc", "partId": "{partId}", "partNumber": "{partNumber}", "workspaceId": "{wid}" } ] } response = requests.post( api_url, params=queryParams, json=body, auth=auth, headers=headers ) print(json.dumps(response.json(), indent=4))
- The next available
partNumber
is listed in the response. See Metadata: Update a part number for steps on updating the part with this new information.
Get latest revision info
Endpoint
GET /revisions/{cd}/{cdid}/p/{pnum}/latest
Query Params
{
"et": 0
}
See the API Explorer for a full list for allowed values and additional parameter options.
Example
- Call getPartsWMVE to get the part’s
partNumber
. - Call getLatestInDocumentOrCompany, using the
partNumber
as thepnum
param.curl -X 'POST' \ 'https://{basUrl}.onshape.com/api/v10/revisions/d/{did}/p/{pnum}/latest?et=0' \ -H 'Accept: application/json;charset=UTF-8; qs=0.09' \ -H 'Authorization: Basic {credentials}' \ -H 'Content-Type: application/json;charset=UTF-8; qs=0.09'
import requests import json auth = (access_key, secret_key) # See Authentication guide headers = { 'Accept': 'application/json;charset=UTF-8;qs=0.09', 'Content-Type': 'application/json;charset=UTF-8; qs=0.09' } api_url = "https://{baseUrl}.onshape.com/api/v10/revisions/d/{did}/p/{pnum}/latest" queryParams = { "et": 0 } response = requests.get( api_url, params=queryParams, auth=auth, headers=headers ) print(json.dumps(response.json(), indent=4))
- Note that you could also use
/c/{cid}
to submit a company ID instead of a document ID. Either is acceptable.
- Note that you could also use
- From the response, locate the
releaseName
andrevision
fields.
Get all revisions
The following endpoints all return revision information for the specified items:
Endpoints | Description |
---|---|
GET /revisions/companies/{cid}/partnumber/{pnum} | Get all revisions for a part number. |
GET /revisions/companies/{cid}/d/{did}/e/{eid}/p/{pid} | Get all revisions for a part ID. |
GET /revisions/companies/{cid} | Get all revisions for a company. |
GET /revisions/d/{did} | Get all revisions for a document. |
GET /revisions/companies/{cid}/d/{did}/{wv}/{wvid}/e/{eid} | Get all revisions for an element. |
GET /revisions/d/{did}/v/{vid} | Get all revisions for a version. |
Query Params
{
"elementType": 0
}
See the API Explorer for a full list for allowed values and additional parameter options.
Example
- Call findCompany to get your company ID.
- Use
id
from the response (NOTaddress.id
orownerId
) as thecid
in Step 4.
- Use
- Call getPartsWMVE to get the part’s
partNumber
. Use this value as thepnum
param in Step 4. - Call getRevisionByPartNumber.
curl -X 'POST' \ 'https://{basUrl}.onshape.com/api/v10/revisions/c/{cid}/partnumber/{pnum}/?elementType=0' \ -H 'Accept: application/json;charset=UTF-8; qs=0.09' \ -H 'Authorization: Basic {credentials}' \ -H 'Content-Type: application/json;charset=UTF-8; qs=0.09'
import requests import json auth = (access_key, secret_key) # See Authentication guide headers = { 'Accept': 'application/json;charset=UTF-8;qs=0.09', 'Content-Type': 'application/json;charset=UTF-8; qs=0.09' } api_url = "https://{baseUrl}.onshape.com/api/v10/revisions/c/{cid}/partnumber/{pnum}/" queryParams = { "elementType": 0 } response = requests.get( api_url, params=queryParams, auth=auth, headers=headers ) print(json.dumps(response.json(), indent=4))
- Review the response, which includes information for each revision. Each item in the list includes the
releaseName
andrevision
fields.
Additional Resources
- API Explorer: Revision Endpoints
- API Explorer: Release Package Endpoints
- API Explorer: Part Number Endpoints
- API Guide: Using the API Explorer
- Onshape Help: Release Management