Managing B2B prospects
Learn how to register a B2B buyer organization as a prospect using core VTEX platform APIs, then review it and move it through approval or rejection.
This feature is only available for stores using B2B Buyer Portal, which is currently available to selected accounts.
A prospect is a buyer organization that has registered but is not yet cleared to buy. It is a contract held inactive while its review runs.
B2B Buyer Portal stores the prospect contract, address, and storefront user profile in Master Data v1, as documents in the CL, AD, and shopper entities. For how these records relate, see B2B Buyer Portal Master Data architecture and Master Data.
Prospect registration is integrator-driven. VTEX exposes no prospect-registration endpoint, so you assemble the prospect yourself by calling core platform APIs directly. Use the B2B Contracts API for the CL contract document, the B2B Addresses API for the AD address, and the Organization Units API for the unit that scopes the contract. The storefront user comes from Authenticator, License Manager, and the shopper entity, the Master Data entity that holds the storefront user's profile data.
A prospect is a CL document carrying three values:
prospectWorkflowset toPENDINGapprovedset tofalseisActiveset tofalse
Everything else on the document is a normal contract.
If you omit
prospectWorkflowwhen you create theCLdocument, the field staysnulland the record is an ordinary contract, not a prospect. It will not be returned when you search for prospects by state.
This guide covers what must exist for a prospect to be reviewable, how to confirm it, and how to move the prospect between review states.
Before you begin
- The store must have B2B Buyer Portal enabled.
- Requests must be authenticated with an App Key and App Token pair or with a valid
VtexIdclientAutCookieheader. Learn more about API authentication. - The user or API key must hold the License Manager resources listed in the Permissions section of each endpoint you call. Writing
CLandADdocuments requires Dynamic Storage resources, the License Manager resource family that covers Master Data document operations. Reading organization units requires Organization Units resources.
1. Create the prospect contract
A prospect starts as a CL document. Three fields define it as a prospect rather than as an ordinary contract:
| Field | Value at creation | Description |
|---|---|---|
prospectWorkflow | PENDING | Review state of the prospect. The three values are PENDING (under review), APPROVED (review accepted the prospect), and REJECTED (review refused it). Stored values are uppercase. null means the record is an ordinary contract. |
approved | false | Indicates whether the contract is approved to operate. |
isActive | false | Keeps the contract inactive while its review runs. |
Request example
_17curl -X POST "https://{{accountName}}.vtexcommercestable.com.br/api/dataentities/CL/documents" \_17 -H "VtexIdclientAutCookie: {{VtexIdclientAutCookie}}" \_17 -H "Content-Type: application/json" \_17 -H "Accept: application/json" \_17 -d '{_17 "email": "purchasing@acme.com",_17 "firstName": "Acme",_17 "lastName": "Industries",_17 "corporateName": "Acme Industries Ltd",_17 "tradeName": "Acme Industries",_17 "document": "00000000000000",_17 "documentType": "CNPJ",_17 "isCorporate": true,_17 "prospectWorkflow": "PENDING",_17 "approved": false,_17 "isActive": false_17 }'
The response returns documentId, which is the contract ID. The remaining steps use it.
For the complete field list and the field descriptions, see
POSTCreate contract.
2. Requirements before prospect review
The contract alone is not reviewable. A prospect is a set of related records spread across several platform APIs, and the following table lists only what the prospect flow requires of each piece. For the entity-relationship context, the full field inventory, and the linking fields between these entities, see B2B Buyer Portal Master Data architecture.
| Piece | Owning API | What the prospect flow requires | Required before approval |
|---|---|---|---|
Contract (CL) | B2B Contracts API | prospectWorkflow set to PENDING, approved set to false, and isActive set to false. | ✅ |
| Organization unit | Organization Units API | One unit in Organization Units whose contractIds scope contains the contract ID. | ✅ |
Address (AD) | B2B Addresses API | At least one address whose userId is the contract ID and whose isActive is true. | ✅ |
| Storefront user | Authenticator API, Storefront Roles API, and B2B Buyer Data API | An Authenticator user assigned to the organization unit, storefront roles assigned in License Manager, and a shopper document holding the buyer's profile data. See B2B user provisioning. | ❌ |
The storefront user is what lets the buyer sign in to their Organization Account. It is not part of the eligibility conditions, so a prospect can be reviewed before it has one.
3. Review the prospect
3.1 List prospects by state
To list prospects, you can use the Master Data search operation on the CL data entity and filter by prospectWorkflow. Values in _where are uppercase.
_10curl -X GET "https://{{accountName}}.vtexcommercestable.com.br/api/dataentities/CL/search?_where=prospectWorkflow=PENDING&_fields=id,email,corporateName,prospectWorkflow,approved,isActive" \_10 -H "VtexIdclientAutCookie: {{VtexIdclientAutCookie}}" \_10 -H "REST-Range: resources=0-99" \_10 -H "Accept: application/json"
To list the contracts that never went through prospect review, filter by _where=prospectWorkflow is null.
The
REST-Rangeheader is required, and a single query returns at most 100 documents. For the query syntax, pagination headers, and response shape, seeGETSearch documents.
3.2 Confirm eligibility
Two conditions must hold before you approve a prospect, and both are yours to check. Run them against the contract ID returned in Step 1.
First, confirm that an organization unit's contractIds scope contains the contract ID. The request must return at least one unit. A 204 No Content or a 404 Not Found response means no unit references the contract.
_10curl -X GET "https://{{accountName}}.vtexcommercestable.com.br/api/organization-units/v1/scope/contractIds/value/{{contractId}}" \_10 -H "VtexIdclientAutCookie: {{VtexIdclientAutCookie}}" \_10 -H "Content-Type: application/json" \_10 -H "Accept: application/json"
Second, confirm that at least one active address references the contract ID in userId.
_10curl -X GET "https://{{accountName}}.vtexcommercestable.com.br/api/dataentities/AD/search?_where=userId={{contractId}}%20AND%20isActive=true&_fields=id,userId,isActive" \_10 -H "VtexIdclientAutCookie: {{VtexIdclientAutCookie}}" \_10 -H "REST-Range: resources=0-10" \_10 -H "Accept: application/json"
For the full operation details, see
GETFind all organization units with scope value andGETSearch B2B addresses.
3.3 Approve or reject the prospect
You move a prospect between review states by updating prospectWorkflow on its CL document.
To approve a prospect, send prospectWorkflow as APPROVED together with approved as true. On a direct write to the CL document, you set approved yourself and you run the eligibility checks yourself.
A direct write does not refuse an ineligible approval. Confirm first that a prospect is eligible by following the eligibility confirmation steps mentioned above.
A prospect approved through a direct write is equivalent to one approved in the prospect review interface, which runs the same checks and will not approve while those entities are missing.
To reject a prospect, send prospectWorkflow as REJECTED and keep approved as false.
Approval provisions nothing. It creates no organization unit, no address, and no storefront user, which is why those records must already exist.
_10curl -X PATCH "https://{{accountName}}.vtexcommercestable.com.br/api/dataentities/CL/documents/{{contractId}}" \_10 -H "VtexIdclientAutCookie: {{VtexIdclientAutCookie}}" \_10 -H "Content-Type: application/json" \_10 -H "Accept: application/json" \_10 -d '{_10 "prospectWorkflow": "APPROVED",_10 "approved": true_10 }'
CL documents are stored in Master Data v1, where a PATCH request updates the fields you send and leaves the other fields of the document unchanged, so a transition request carries only the fields the transition changes.
For the full field list and the field descriptions, see
PATCHUpdate contract by ID. For the partial update behavior, seePATCHUpdate partial document.
After approval
An approved prospect is a contract approved to operate: approved carries true, and prospectWorkflow stays as APPROVED, keeping a record of the review on the document.
Contracts created before the prospect workflow existed carry prospectWorkflow as null and are unaffected by it.
Next steps
Give the buyer organization its users and permissions. See B2B user provisioning.