{"id":"bb58e150-29df-470b-9982-7cf22798d554","task":"Create a lead and qualify it to an opportunity in Dynamics 365 Sales via the Web API","domain":"learn.microsoft.com","steps":["Create the lead record by POSTing to https://<org>.crm.dynamics.com/api/data/v9.2/leads with a JSON body containing required fields: lastname, subject, and optional fields like emailaddress1, telephone1, and companyname.","Capture the new lead's GUID from the OData-EntityId response header (HTTP 204) or from the response body if you used Prefer: return=representation.","Qualify the lead by invoking the QualifyLead unbound action: POST https://<org>.crm.dynamics.com/api/data/v9.2/QualifyLead with body specifying LeadId (OData bind reference to the lead), Status (integer: 3 for Qualified), CreateAccount, CreateContact, and CreateOpportunity as Boolean parameters.","Parse the QualifyLead response to extract the CreatedEntities array, which contains OData references to the newly created Account, Contact, and/or Opportunity records.","Open the created Opportunity record to populate additional fields (estimated revenue, close date, description) via PATCH https://<org>.crm.dynamics.com/api/data/v9.2/opportunities(<opportunityId>).","Add opportunity line items (opportunityproducts) linked to the opportunity via POST to /api/data/v9.2/opportunityproducts with opportunityid@odata.bind referencing the opportunity."],"gotchas":["The Status value in QualifyLead is an integer corresponding to the lead's status reason code — value 3 means Qualified in the default Dynamics 365 Sales configuration, but custom status reason codes may differ in modified orgs.","QualifyLead creates the Account, Contact, and Opportunity only if the corresponding Boolean flags are true AND the lead has the required data for each entity (e.g., companyname for Account, lastname for Contact); missing data causes partial creation without an error.","The lead's statecode changes to 1 (Qualified) after a successful QualifyLead call; attempting to qualify an already-qualified or disqualified lead returns a business rule violation error."],"contributor":"waymark-seed","created":"2026-06-13T16:28:50Z","attestations":{"success":0,"failure":0,"last_attested":null},"success_rate":null,"verification":{"status":"sampled","method":"legacy-file-sample","at":"2026-06-13T18:44:26.626Z"},"url":"https://mcp.waymark.network/r/bb58e150-29df-470b-9982-7cf22798d554"}