Skip to content
Last updated

Complete Prospects Order Workflow

Overview

This workflow demonstrates the full Prospects API integration journey for discovering and pre-qualifying look-alike businesses using Creditsafe data:

  1. Authenticate - Obtain JWT token for API access
  2. Preview Order - Estimate the number of matching companies before creating an order
  3. Create Order - Submit a prospect order based on search criteria
  4. Get Order Details - Retrieve the order status and results summary
  5. Export Order - Download the order results in your preferred format (xls, xlsx, or csv)

Workflow Diagram

Yes

No

Yes 200

No 202

Step 1: Authenticate

Step 2: Preview Order

Step 3: Create Order

Step 4: Get Order Details

Order Complete?

Step 5: Export Order

Export Ready?

Download File

Yes

No

Yes 200

No 202

Step 1: Authenticate

Step 2: Preview Order

Step 3: Create Order

Step 4: Get Order Details

Order Complete?

Step 5: Export Order

Export Ready?

Download File

Diagram summary: This workflow shows the complete Prospects order lifecycle. After authentication, the user previews an order to estimate matches, creates the order, polls for order completion, and exports the results. The export step may return 202 Accepted if still processing, requiring a retry.


Sequence Diagram

Creditsafe BackendProspects APIClientCreditsafe BackendProspects APIClientStep 1: AuthenticateStep 2: Preview Orderalt[Success][Validation Error (400)][Auth Error (401)][Credit Error (403)]Step 3: Create Orderalt[Success][Validation Error (400)][Auth Error (401)][Credit Error (403)]Step 4: Get Order Detailsalt[Success][Not Found (404)]Step 5: Export Orderalt[Export Ready][Export Processing][Not Found (404)]POST /authenticate200 OK {token}POST /prospects/orders/previewValidate criteria & estimate matchesMatch count by country200 OK {totalCount, breakdown}400 Bad Request {correlationId, message, details}401 Unauthorized403 ForbiddenPOST /prospects/ordersCreate order & processOrder created {orderId}200 OK {orderId}400 Bad Request401 Unauthorized403 ForbiddenGET /prospects/orders/{id}200 OK {status, results}404 Not FoundGET /prospects/orders/{id}/export200 OK {binary file}202 Accepted404 Not Found
Creditsafe BackendProspects APIClientCreditsafe BackendProspects APIClientStep 1: AuthenticateStep 2: Preview Orderalt[Success][Validation Error (400)][Auth Error (401)][Credit Error (403)]Step 3: Create Orderalt[Success][Validation Error (400)][Auth Error (401)][Credit Error (403)]Step 4: Get Order Detailsalt[Success][Not Found (404)]Step 5: Export Orderalt[Export Ready][Export Processing][Not Found (404)]POST /authenticate200 OK {token}POST /prospects/orders/previewValidate criteria & estimate matchesMatch count by country200 OK {totalCount, breakdown}400 Bad Request {correlationId, message, details}401 Unauthorized403 ForbiddenPOST /prospects/ordersCreate order & processOrder created {orderId}200 OK {orderId}400 Bad Request401 Unauthorized403 ForbiddenGET /prospects/orders/{id}200 OK {status, results}404 Not FoundGET /prospects/orders/{id}/export200 OK {binary file}202 Accepted404 Not Found

Diagram summary: This sequence diagram shows the interaction between the client, Prospects API, and Creditsafe backend. Step 1 authenticates and returns a token. Step 2 previews the order with validation, showing success (200), validation errors (400), authentication errors (401), and credit errors (403). Step 3 creates the order, returning an orderId. Step 4 retrieves order details, showing success (200) and not found (404) paths. Step 5 exports results, showing ready (200), processing (202), and not found (404) responses.


Error Handling

All endpoints follow standard Prospects API error patterns. Errors include a correlationId for support tracking.

Common HTTP Status Codes

CodeMeaningTypical CauseAction
400Bad RequestInvalid search criteria, validation failureCheck request body against schema, verify enum values and required fields
401UnauthorizedInvalid/expired tokenRe-authenticate using Step 1
403ForbiddenInsufficient permissions or creditsVerify account permissions and credit balance
404Not FoundOrder doesn't existVerify order ID from Step 3 output
202AcceptedExport still processingRetry Step 5 after a short delay (e.g., 5-10 seconds)
500Internal Server ErrorSystem issueRetry with exponential backoff (2s, 4s, 8s)

Error Response Format

{
  "correlationId": "550e8400-e29b-41d4-a716-446655440000",
  "message": "Validation failed",
  "details": "Invalid country code: 'XX' is not a supported country"
}

Retry Guidelines

  • 401 (Unauthorized): Re-authenticate once, then fail
  • 403 (Forbidden): Do not retry (permission or credit issue)
  • 404 (Not Found): Do not retry in workflow (indicates data flow error)
  • 202 (Accepted): Retry Step 5 (export) with delays until 200 received
  • 500/503 (Server Errors): Retry up to 3 times with exponential backoff

Step 1: Authenticate

Authenticate with username and password to obtain a JWT token for API access.

Applies To: All workflows

Endpoint

POST /authenticate

Request Parameters

ParameterTypeDescription
usernamestringProspects API username for authentication
passwordstringProspects API password for authentication

Example Request

{
  "username": "your-username",
  "password": "your-password"
}

Example Response

{
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}

Success Criteria

Condition
HTTP Status Code = 200
token field returned in response body

Common Errors

StatusCause
400Invalid username or password format
401Incorrect credentials

Step 2: Preview Order

Preview the number of matching companies for prospect search criteria before creating an order. Returns a breakdown by country and registration type to help estimate scope and cost.

Applies To: Complete order workflow (optional but recommended)

Endpoint

POST /prospects/orders/preview

Request Parameters

ParameterTypeDescription
Authorizationstring (header)Bearer token from Step 1
Request body contains search criteria (countries, industries, employee ranges, etc.)objectProspect search criteria matching API schema

Example Request

{
  "countries": ["GB", "US"],
  "industries": ["62", "70"],
  "employeeRange": {
    "min": 10,
    "max": 100
  }
}

Example Response

{
  "totalCount": 1250,
  "breakdown": [
    {
      "country": "GB",
      "registrationType": "Limited",
      "count": 850
    },
    {
      "country": "US",
      "registrationType": "Corporation",
      "count": 400
    }
  ]
}

Success Criteria

Condition
HTTP Status Code = 200
totalCount field returned
breakdown array returned with country-level counts

Common Errors

StatusCause
400Invalid search criteria (e.g., unsupported country code, invalid enum values)
401Invalid or expired authentication token
403Insufficient permissions to preview orders

Step 3: Create Order

Create a new prospects order based on search criteria. This endpoint orders a list of companies matching specific criteria for prospecting and business development.

Applies To: Complete order workflow

Endpoint

POST /prospects/orders

Request Parameters

ParameterTypeDescription
Authorizationstring (header)Bearer token from Step 1
Request body contains search criteriaobjectProspect search criteria (same structure as Step 2)

Example Request

{
  "countries": ["GB", "US"],
  "industries": ["62", "70"],
  "employeeRange": {
    "min": 10,
    "max": 100
  }
}

Example Response

{
  "orderId": "a3f2b1d5-8c4e-4f2a-9e7b-1c5d6e8f9a0b",
  "status": "Processing",
  "createdDate": "2026-07-22T10:30:00Z"
}

Success Criteria

Condition
HTTP Status Code = 200
orderId field returned (GUID format)

Common Errors

StatusCause
400Invalid search criteria or request format
401Invalid or expired authentication token
403Insufficient credits or permissions to create order

Step 4: Get Order Details

Retrieve details of a specific prospect order by its unique identifier. Returns order status, progress information, search criteria used, and results summary when the order is completed.

Applies To: Complete order workflow

Endpoint

GET /prospects/orders/{id}

Request Parameters

ParameterTypeDescription
Authorizationstring (header)Bearer token from Step 1
idstring (path)Order ID from Step 3 (GUID format)

Example Response

{
  "orderId": "a3f2b1d5-8c4e-4f2a-9e7b-1c5d6e8f9a0b",
  "status": "Completed",
  "createdDate": "2026-07-22T10:30:00Z",
  "completedDate": "2026-07-22T10:35:00Z",
  "totalResults": 1250,
  "searchCriteria": {
    "countries": ["GB", "US"],
    "industries": ["62", "70"]
  }
}

Success Criteria

Condition
HTTP Status Code = 200
orderId matches requested ID
status field indicates order progress

Common Errors

StatusCause
401Invalid or expired authentication token
404Order not found (invalid order ID or unauthorized access)

Step 5: Export Order

Export the results of a completed prospect order as a downloadable file. Supports xls, xlsx, and csv formats. If the export is still being processed, returns 202 Accepted and should be retried.

Applies To: Complete order workflow (after order is completed)

Endpoint

GET /prospects/orders/{id}/export?fileFormat={format}

Request Parameters

ParameterTypeDescription
Authorizationstring (header)Bearer token from Step 1
idstring (path)Order ID from Step 3 (GUID format)
fileFormatstring (query)Export file format: xls, xlsx, or csv (optional)

Example Response (200 - Ready)

Binary file stream (xls/xlsx/csv content)

Example Response (202 - Processing)

{
  "message": "Export is still being processed. Please retry in a few moments.",
  "estimatedCompletionTime": "2026-07-22T10:40:00Z"
}

Success Criteria

Condition
HTTP Status Code = 200
Binary file stream returned

Common Errors

StatusCause
202Export still processing - retry after short delay
400Invalid file format parameter
401Invalid or expired authentication token
404Order not found or export not available

Implementation Notes

Polling Strategy for Order Completion

After creating an order (Step 3), poll Step 4 (Get Order Details) to check order status:

  • Recommended interval: 5-10 seconds
  • Maximum retries: 60 attempts (5-10 minutes total)
  • Check: status field equals "Completed" before proceeding to Step 5

Polling Strategy for Export Readiness

After requesting export (Step 5), if you receive 202 Accepted:

  • Recommended interval: 5-10 seconds
  • Maximum retries: 30 attempts (2.5-5 minutes total)
  • Success: HTTP 200 with binary file stream

File Format Selection

Choose the export format based on your downstream systems:

  • CSV: Lightweight, universal compatibility, best for data import
  • XLSX: Excel format with formatting support, best for manual review
  • XLS: Legacy Excel format, use only for compatibility requirements