---
title: Query Opportunities
slug: query-opportunities
docTags: 
createdAt: 2026-08-25T19:28:59.170Z
---

{
  "id": "eyLIC9TH9_-1onZqmfamN",
  "type": "api-oas-v2",
  "data": {
    "method": "GET",
    "url": "https://api.nue.io/cpq/opportunities",
    "servers": [
      {
        "url": "https://api.nue.io/cpq/opportunities",
        "description": "Nue Production API Endpoint"
      },
      {
        "url": "https://api.sandbox.nue.io/cpq/opportunities",
        "description": "Nue Sandbox API Endpoint"
      }
    ],
    "name": "Query Opportunities",
    "description": "<p>Retrieve opportunities associated with a specific Salesforce account ID. If stageNames is provided, filters by those stages. If not provided, excludes 'Closed Won' and 'Closed Lost' opportunities by default.</p>",
    "contentType": "application/json",
    "request": {
      "pathParameters": [],
      "headerParameters": [
        {
          "name": "accept",
          "type": "string",
          "kind": "optional",
          "description": "Generated from available response content types",
          "enum": [
            "application/json"
          ],
          "default": "application/json"
        }
      ],
      "queryParameters": [
        {
          "kind": "required",
          "name": "accountId",
          "type": "string",
          "example": "001XXXXXXXXXXXXXXX",
          "description": "The Salesforce account ID to query opportunities for",
          "pattern": "^[a-zA-Z0-9]{15,18}$"
        },
        {
          "kind": "optional",
          "name": "stageNames",
          "type": "array",
          "description": "<p>Optional list of opportunity stages to filter by (e.g., Prospecting, Qualification, Closed Won)</p>",
          "schema": [],
          "itemType": "string",
          "customType": "string[]"
        }
      ],
      "bodyDataParameters": [],
      "formDataParameters": [],
      "oAuthParameters": [
        {
          "id": "ApiKeyAuth",
          "name": "nue-api-key",
          "kind": "optional",
          "type": "apiKey",
          "in": "header"
        }
      ],
      "cookieParameters": []
    },
    "responses": [
      {
        "statusCode": "200",
        "description": "Opportunities retrieved successfully",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "description": "Response from querying opportunities by account",
            "customType": "OpportunityQueryResponse",
            "schema": [
              {
                "name": "accountId",
                "kind": "optional",
                "type": "string",
                "description": "The account ID that was queried"
              },
              {
                "name": "opportunities",
                "kind": "optional",
                "type": "array",
                "description": "",
                "example": "",
                "itemType": "object",
                "customType": "object[]",
                "schema": [
                  {
                    "name": "id",
                    "kind": "optional",
                    "type": "string",
                    "description": "Opportunity ID"
                  },
                  {
                    "name": "name",
                    "kind": "optional",
                    "type": "string",
                    "description": "Opportunity name"
                  },
                  {
                    "name": "stage",
                    "kind": "optional",
                    "type": "string",
                    "description": "Current stage"
                  },
                  {
                    "name": "closeDate",
                    "kind": "optional",
                    "type": "string<date>",
                    "description": "Expected close date",
                    "format": "date"
                  },
                  {
                    "name": "accountId",
                    "kind": "optional",
                    "type": "string",
                    "description": "Account ID"
                  },
                  {
                    "name": "description",
                    "kind": "optional",
                    "type": "string",
                    "description": "Description"
                  },
                  {
                    "name": "nextStep",
                    "kind": "optional",
                    "type": "string",
                    "description": "Next step"
                  },
                  {
                    "name": "salesforceUrl",
                    "kind": "optional",
                    "type": "string",
                    "description": "Salesforce URL"
                  }
                ]
              }
            ],
            "modelRef": "#/components/schemas/OpportunityQueryResponse",
            "isExpanded": true
          }
        ]
      },
      {
        "statusCode": "400",
        "description": "<p>Bad Request - Invalid account ID format</p>",
        "jsonExample": "",
        "isExpanded": true
      },
      {
        "statusCode": "404",
        "description": "<p>Not Found - Account not found or no opportunities exist</p>",
        "jsonExample": "",
        "isExpanded": true
      }
    ],
    "hasXCodeSamples": false,
    "examples": {
      "languages": [
        {
          "id": "eQWvOy4mMiQAX6T-_fr89",
          "language": "curl",
          "label": "cURL",
          "code": "curl --request GET \\\n     --url 'https://api.nue.io/cpq/opportunities?accountId=001XXXXXXXXXXXXXXX' \\\n     --header 'accept: application/json'"
        },
        {
          "id": "J_cyJLM3TnaJIB1xKqyFr",
          "language": "javascript",
          "label": "javascript",
          "code": "var myHeaders = new Headers();\nmyHeaders.append(\"accept\", \"application/json\");\nmyHeaders.append(\"content-type\", \"application/json\");\n\nvar requestOptions = {\n   method: 'GET',\n   headers: myHeaders,\n   redirect: 'follow'\n};\n\nfetch(\"https://api.nue.io/cpq/opportunities?accountId=001XXXXXXXXXXXXXXX\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));"
        },
        {
          "id": "QuSthfUIDTm34HiyQM_2H",
          "language": "ruby",
          "label": "Ruby",
          "code": "require \"uri\"\nrequire \"json\"\nrequire \"net/http\"\n\nurl = URI(\"https://api.nue.io/cpq/opportunities?accountId=001XXXXXXXXXXXXXXX\")\n\nhttps = Net::HTTP.new(url.host, url.port)\nhttps.use_ssl = true\n\nrequest = Net::HTTP::Get.new(url)\nrequest[\"accept\"] = \"application/json\"\nrequest[\"content-type\"] = \"application/json\"\n\nresponse = https.request(request)\nputs response.read_body\n"
        },
        {
          "id": "ip7QLp3OsaotVVJuEgJqw",
          "language": "python",
          "label": "Python",
          "code": "import requests\nimport json\n\nurl = \"https://api.nue.io/cpq/opportunities?accountId=001XXXXXXXXXXXXXXX\"\n\npayload = {}\nheaders = {\n   'accept': 'application/json',\n   'content-type': 'application/json'\n}\n\nresponse = requests.request(\"GET\", url, headers=headers, data=payload)\n\nprint(response.text)\n"
        }
      ],
      "selectedLanguageId": "eQWvOy4mMiQAX6T-_fr89"
    },
    "results": {
      "languages": [
        {
          "id": "7h2LYqYnsn08tqpPxBiCj",
          "language": "200",
          "code": "// Opportunities retrieved successfully\n{\n  \"accountId\": \"\",\n  \"opportunities\": [\n    {\n      \"id\": \"\",\n      \"name\": \"\",\n      \"stage\": \"\",\n      \"closeDate\": \"\",\n      \"accountId\": \"\",\n      \"description\": \"\",\n      \"nextStep\": \"\",\n      \"salesforceUrl\": \"\"\n    }\n  ]\n}"
        },
        {
          "id": "hz_2r15POHsGV1KY9H7XG",
          "language": "400",
          "code": "// Bad Request - Invalid account ID format\n"
        },
        {
          "id": "uFhYUl5xVK7NZloqf-F8N",
          "language": "404",
          "code": "// Not Found - Account not found or no opportunities exist\n"
        }
      ],
      "selectedLanguageId": "7h2LYqYnsn08tqpPxBiCj"
    }
  },
  "children": [
    {
      "text": ""
    }
  ]
}