Release Management

This page describes the APIs Onshape provides for working with revisions and part numbers.

Prerequisites
  • All Onshape API calls must be properly authenticated.
    • See the API Keys page for instructions and the Quick Start for an example.
    • All applications submitted to the Onshape App Store must authenticate with OAuth2.
  • For Standard accounts, replace {baseUrl} with cad in all endpoints. For Enterprise accounts, replace it with your company domain. Add /api and the version number, and then provide the endpoint.
    • https://{baseUrl}.onshape.com/api/v10/documents
    • https://cad.onshape.com/api/v10/documents
    • https://companySubDomain.onshape.com/api/v10/documents
  • Onshape IDs are written as: {did}, {wvmid}, {eid}, {pid}, {otherId}.
    • These represent document, workspace (or version or microversion), element, part, and other IDs, respectively.
    • Never include the braces {} with your IDs.
    • See API Guide: API Intro for information on what these IDs mean and how to obtain them from your documents.
  • This page provides sample code in cURL and python.
  • For additional instruction and video content, visit the Learning Center’s Intro to the Onshape API course.

Examples


Get the next available part number

Endpoint

POST /partnumber/nextnumbers

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

  1. Call findCompany to get your company ID.
    • Use id from the response (NOT address.id or ownerId) as the cid in Step 3.
  2. Call getPartsWMV or getPartsWMVE to get the part’s partNumber and partId.
  3. 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))
    
  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

  1. Call getPartsWMVE to get the part’s partNumber.
  2. Call getLatestInDocumentOrCompany, using the partNumber as the pnum 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.
  3. From the response, locate the releaseName and revision fields.

Get all revisions

The following endpoints all return revision information for the specified items:

EndpointsDescription
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

  1. Call findCompany to get your company ID.
    • Use id from the response (NOT address.id or ownerId) as the cid in Step 4.
  2. Call getPartsWMVE to get the part’s partNumber. Use this value as the pnum param in Step 4.
  3. 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))
    
  4. Review the response, which includes information for each revision. Each item in the list includes the releaseName and revision fields.

Additional Resources