Skip to main content
Merchant Category Code (MCC) verification is another important aspect of KYB processes. This example demonstrates how to use the Parcha API to verify a business’s MCC code based on its basic information.

Step 1: Prepare Business Data and Run MCC Code Verification

Use the runCheck endpoint to initiate the MCC code verification process.
curl -X POST 'https://demo.parcha.ai/api/v1/runCheck' \
-H 'Authorization: Bearer YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
  "agent_key": "your-agent-key",
  "kyb_schema": {
    "id": "unique-case-id",
    "self_attested_data": {
      "business_name": "TechInnovate Solutions",
      "description": "Providing cutting-edge software solutions for businesses",
      "website": "https://techinnovatesolutions.com",
      "country_code": "US"
    }
  },
  "check_id": "kyb.mcc_code_check_v3",
  "webhook_url": "https://your-webhook-url.com/callback"
}'
import requests

api_key = 'YOUR_API_KEY'
url = 'https://demo.parcha.ai/api/v1/runCheck'

data = {
    "agent_key": "your-agent-key",
    "kyb_schema": {
        "id": "unique-case-id",
        "self_attested_data": {
            "business_name": "TechInnovate Solutions",
            "description": "Providing cutting-edge software solutions for businesses",
            "website": "https://techinnovatesolutions.com",
            "country_code": "US"
        }
    },
    "check_id": "kyb.mcc_code_check_v3",
    "webhook_url": "https://your-webhook-url.com/callback"
}

headers = {
    'Authorization': f'Bearer {api_key}',
    'Content-Type': 'application/json'
}

response = requests.post(url, json=data, headers=headers)
print(response.json())
import axios from 'axios';

const apiKey = 'YOUR_API_KEY';
const url = 'https://demo.parcha.ai/api/v1/runCheck';

const data = {
  agent_key: "your-agent-key",
  kyb_schema: {
    id: "unique-case-id",
    self_attested_data: {
      business_name: "TechInnovate Solutions",
      description: "Providing cutting-edge software solutions for businesses",
      website: "https://techinnovatesolutions.com",
      country_code: "US"
    }
  },
  check_id: "kyb.mcc_code_check",
  webhook_url: "https://your-webhook-url.com/callback"
};

axios.post(url, data, {
  headers: {
    'Authorization': `Bearer ${apiKey}`,
    'Content-Type': 'application/json'
  }
})
.then(response => console.log(response.data))
.catch(error => console.error('Error:', error));

Step 2: Poll for Job Status (Optional if using webhook)

If you’re not using a webhook, you can poll for the job status using the getJobById endpoint.
curl 'https://demo.parcha.ai/api/v1/getJobById?job_id=YOUR_JOB_ID&include_check_results=true' \
-H 'Authorization: Bearer YOUR_API_KEY'
import requests
import time

api_key = 'YOUR_API_KEY'
job_id = 'YOUR_JOB_ID'
url = f'https://demo.parcha.ai/api/v1/getJobById?job_id={job_id}&include_check_results=true'

headers = {
    'Authorization': f'Bearer {api_key}'
}

while True:
    response = requests.get(url, headers=headers)
    job_data = response.json()
    
    if job_data['status'] == 'complete':
        print("Job completed!")
        print(job_data)
        break
    else:
        print("Job still in progress. Waiting...")
        time.sleep(5)  # Wait for 5 seconds before checking again
import axios from 'axios';

const apiKey = 'YOUR_API_KEY';
const jobId = 'YOUR_JOB_ID';
const url = `https://demo.parcha.ai/api/v1/getJobById?job_id=${jobId}&include_check_results=true`;

function pollJobStatus() {
  axios.get(url, {
    headers: {
      'Authorization': `Bearer ${apiKey}`
    }
  })
  .then(response => {
    const jobData = response.data;
    if (jobData.status === 'complete') {
      console.log("Job completed!");
      console.log(jobData);
    } else {
      console.log("Job still in progress. Waiting...");
      setTimeout(pollJobStatus, 5000);  // Check again after 5 seconds
    }
  })
  .catch(error => console.error('Error:', error));
}

pollJobStatus();

Step 3: Process the Results

Once the job is completed, examine the results to retrieve the MCC code and its description.
Python
if job_data['status'] == 'complete':
    mcc_check_result = next(
        (result for result in job_data['check_results']
         if result['command_id'] == 'kyb.mcc_code_check_v3'),
        None
    )
    if mcc_check_result:
        payload = mcc_check_result['payload']
        mcc_code = payload.get('mcc_code')
        mcc_title = payload.get('mcc_title')
        mcc_description = payload.get('mcc_code_description')
        print(f"MCC Code: {mcc_code}")
        print(f"Title: {mcc_title}")
        print(f"Description: {mcc_description}")
    else:
        print("MCC code check result not found.")
Or use JSONPath for cleaner extraction:
Python
from urllib.parse import quote

jsonpath_query = '$.check_results[?(@.command_id=="kyb.mcc_code_check_v3")].payload'
url = f'https://demo.parcha.ai/api/v1/getJobById?job_id={job_id}&include_check_results=true&jsonpath_query={quote(jsonpath_query)}'

response = requests.get(url, headers=headers)
mcc_payload = response.json()[0]

print(f"MCC Code: {mcc_payload['mcc_code']}")
print(f"Title: {mcc_payload['mcc_title']}")
print(f"Description: {mcc_payload['mcc_code_description']}")

Conclusion

This MCC code verification process demonstrates a straightforward use of the Parcha API:
  1. It requires minimal input (basic business information).
  2. It can be executed with a single API call to runCheck.
  3. Results can be retrieved either through a webhook or by polling the job status.
This approach is efficient for quick verifications that don’t require document uploads or complex multi-step processes. Always ensure that the business information provided is accurate to get the most reliable MCC code verification results.