API Reference

Inquiry Submission API

Complete endpoint documentation for submitting inquiries, retrieving case types, and querying submission history.

API Key Required

Most endpoints require an API key in the X-Api-Key header. Apply for a vendor account to receive your credentials.

1. Authentication

All API requests except the public case types endpoint require your API key in the X-Api-Key header.

X-Api-Key: YOUR_API_KEY

Your API key is available on your Settings page after registration. Browser-based requests also require your whitelisted domains to be registered there, and requests from unregistered origins will be rejected.

If your CRM, posting engine, or backend can send a custom X-Api-Key header, it can post directly to this API. If it cannot send custom headers, use one of the server-side starter files or the WordPress plugin instead.

2. POST https://partners.dipetrillolaw.com/api/leads
Requires API Key

Submit a new inquiry. This endpoint accepts JSON, XML, form-urlencoded, and multipart form data.

Supported Content Types
  • application/json
  • application/xml or text/xml
  • application/x-www-form-urlencoded
  • multipart/form-data
JSON Example
{
  "name": "John Doe",
  "email": "john@example.com",
  "phone": "555-123-4567",
  "caseTypeId": 1,
  "message": "I was in a car accident...",
  "sourceType": 3,
  "sourceUrl": "https://yoursite.com/auto-accident"
}
XML Example
<Lead>
  <Name>John Doe</Name>
  <Email>john@example.com</Email>
  <Phone>555-123-4567</Phone>
  <CaseTypeId>1</CaseTypeId>
  <Message>I was in a car accident...</Message>
  <SourceType>3</SourceType>
  <SourceUrl>https://yoursite.com/auto-accident</SourceUrl>
</Lead>
Source Type Values
ValueMeaning
1AffiliateEmbed — the hosted embed widget
2AffiliateForm — your custom HTML form
3AffiliateAPI — direct REST API call
Response (201 Created)
{
  "leadId": 42,
  "status": "Pending"
}
cURL Example (JSON)
curl -X POST https://partners.dipetrillolaw.com/api/leads \
  -H "Content-Type: application/json" \
  -H "X-Api-Key: YOUR_API_KEY" \
  -d '{
    "name": "John Doe",
    "email": "john@example.com",
    "phone": "555-123-4567",
    "caseTypeId": 1,
    "message": "I need legal representation.",
    "sourceType": 3,
    "sourceUrl": "https://yoursite.com/contact"
  }'
JavaScript (fetch)
fetch("https://partners.dipetrillolaw.com/api/leads", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "X-Api-Key": "YOUR_API_KEY"
  },
  body: JSON.stringify({
    name: "John Doe",
    email: "john@example.com",
    phone: "555-123-4567",
    caseTypeId: 1,
    message: "I need legal representation.",
    sourceType: 3,
    sourceUrl: window.location.href
  })
})
.then(r => r.json())
.then(data => console.log("Submitted:", data))
.catch(err => console.error("Error:", err));
3. GET https://partners.dipetrillolaw.com/api/leads/casetypes
Public — No Key Required

Returns all active case types. Use this to populate dropdowns in your forms or widget.

[
  { "id": 1, "name": "Auto Accident", "practiceArea": 0 },
  { "id": 2, "name": "Truck Accident", "practiceArea": 0 },
  ...
]
4. GET https://partners.dipetrillolaw.com/api/affiliates/leads
Requires API Key

Retrieve all inquiries you have submitted.

[
  {
    "id": 42,
    "name": "John Doe",
    "email": "john@example.com",
    "phone": "555-123-4567",
    "message": "I was in a car accident...",
    "caseType": "Auto Accident",
    "status": "Pending",
    "createdTime": "2026-03-10T12:00:00Z",
    "sourceType": "AffiliateAPI",
    "sourceUrl": "https://yoursite.com/auto-accident"
  }
]
5. GET https://partners.dipetrillolaw.com/api/affiliates/stats
Requires API Key

Retrieve summary statistics for your submissions.

{
  "total": 15,
  "pending": 3,
  "accepted": 10,
  "rejected": 2
}
6. Case Type Reference

Use these IDs for the caseTypeId field when submitting inquiries.

IDNamePractice Area
1 Auto Accident PersonalInjury
2 Truck Accident PersonalInjury
3 Motorcycle Accident PersonalInjury
4 Ride Share Accident PersonalInjury
5 Pedestrian Accident PersonalInjury
6 Slip, Trip & Fall PersonalInjury
7 Wrongful Death PersonalInjury
8 Boating Accident PersonalInjury
9 Dog Bite PersonalInjury
10 Other Inquiries PersonalInjury
11 DUI CriminalDefense
12 Theft CriminalDefense
13 Drug Charges CriminalDefense
14 Misdemeanors CriminalDefense
15 Violent Crimes CriminalDefense
16 Weapons & Firearm Charges CriminalDefense
17 Expunge & Seal Records CriminalDefense
18 Family Law OtherServices
19 Corporate Law OtherServices
20 Civil Litigation OtherServices
7. Integration: Embed Widget

The fastest path to a working intake form. Copy this snippet into any page on your website. The widget renders a styled form, fetches case types automatically, and submits inquiries to the API.

<div id="dp-lead-widget"></div>
<script
  src="https://partners.dipetrillolaw.com/js/embed-widget.js"
  data-api-key="YOUR_API_KEY"
  data-api-url="https://partners.dipetrillolaw.com">
</script>

Want to customize the widget's colors and appearance? Use the Widget Configurator to preview themes and generate a ready-to-use snippet.

8. Integration: Custom HTML Form

For full control over styling, use this HTML form template. Copy it, style it to match your site, and the included JavaScript handles submission.

<form id="dpl-custom-form">
  <input type="text" name="name" placeholder="Full Name" required />
  <input type="email" name="email" placeholder="Email" required />
  <input type="tel" name="phone" placeholder="Phone" required />
  <select name="caseTypeId" id="dpl-casetypes" required>
    <option value="">Select Case Type</option>
  </select>
  <textarea name="message" placeholder="Describe your situation" required></textarea>
  <button type="submit">Get Free Consultation</button>
  <div id="dpl-result"></div>
</form>
<script>
(function() {
  var API = "https://partners.dipetrillolaw.com";
  var KEY = "YOUR_API_KEY";
  // See full template in Downloads section
})();
</script>
9. Error Codes
CodeMeaningCommon Causes
400Bad RequestRequired fields missing, invalid email/phone, or invalid caseTypeId.
401UnauthorizedMissing or invalid X-Api-Key header, or inactive vendor account.
403ForbiddenRequest origin domain is not in your whitelisted domains.
415Unsupported Media TypeUnsupported Content-Type. Use JSON, XML, form-urlencoded, or multipart.
500Server ErrorInternal error. Contact support if this persists.