Skip to content

crm-import ​

← All modules

4 endpoints.

GET /api/v1/crm/import/sources ​

List Sources

The importable ERP sources for this site, with counts + filter fields.

200 — Successful Response

json
{
  "additionalProperties": true,
  "type": "object",
  "title": "Response List Sources Api V1 Crm Import Sources Get"
}

POST /api/v1/crm/import/preview ​

Preview

Dry run — reads the ERP, writes nothing.

Request body

json
{
  "properties": {
    "reuse_existing": {
      "type": "boolean",
      "title": "Reuse Existing",
      "default": false
    },
    "source": {
      "type": "string",
      "title": "Source"
    },
    "filters": {
      "additionalProperties": true,
      "type": "object",
      "title": "Filters"
    },
    "limit": {
      "type": "integer",
      "title": "Limit",
      "default": 5000
    },
    "only_with_phone": {
      "type": "boolean",
      "title": "Only With Phone",
      "default": true
    }
  },
  "type": "object",
  "required": [
    "source"
  ],
  "title": "ImportRequest"
}

200 — Successful Response

json
{
  "additionalProperties": true,
  "type": "object",
  "title": "Response Preview Api V1 Crm Import Preview Post"
}

422 — Validation Error

json
{
  "properties": {
    "detail": {
      "items": {
        "properties": {
          "loc": {
            "items": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "integer"
                }
              ]
            },
            "type": "array",
            "title": "Location"
          },
          "msg": {
            "type": "string",
            "title": "Message"
          },
          "type": {
            "type": "string",
            "title": "Error Type"
          }
        },
        "type": "object",
        "required": [
          "loc",
          "msg",
          "type"
        ],
        "title": "ValidationError"
      },
      "type": "array",
      "title": "Detail"
    }
  },
  "type": "object",
  "title": "HTTPValidationError"
}

POST /api/v1/crm/import/run ​

Run Import

Import an ERP source into a campaign. One transaction: a partial import would leave a campaign with no targets.

Request body

json
{
  "properties": {
    "reuse_existing": {
      "type": "boolean",
      "title": "Reuse Existing",
      "default": false
    },
    "source": {
      "type": "string",
      "title": "Source"
    },
    "filters": {
      "additionalProperties": true,
      "type": "object",
      "title": "Filters"
    },
    "limit": {
      "type": "integer",
      "title": "Limit",
      "default": 5000
    },
    "only_with_phone": {
      "type": "boolean",
      "title": "Only With Phone",
      "default": true
    },
    "campaign_name": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Campaign Name"
    },
    "campaign_id": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Campaign Id"
    },
    "agent_id": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Agent Id"
    }
  },
  "type": "object",
  "required": [
    "source"
  ],
  "title": "RunRequest"
}

200 — Successful Response

json
{
  "additionalProperties": true,
  "type": "object",
  "title": "Response Run Import Api V1 Crm Import Run Post"
}

422 — Validation Error

json
{
  "properties": {
    "detail": {
      "items": {
        "properties": {
          "loc": {
            "items": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "integer"
                }
              ]
            },
            "type": "array",
            "title": "Location"
          },
          "msg": {
            "type": "string",
            "title": "Message"
          },
          "type": {
            "type": "string",
            "title": "Error Type"
          }
        },
        "type": "object",
        "required": [
          "loc",
          "msg",
          "type"
        ],
        "title": "ValidationError"
      },
      "type": "array",
      "title": "Detail"
    }
  },
  "type": "object",
  "title": "HTTPValidationError"
}

POST /api/v1/crm/import/campaign ​

Import Campaign

Land a campaign and its leads from a caller-supplied payload.

The ERP-free sibling of /run — same landing path (so the dedup, contact matching and target creation are identical), for a caller that already holds the rows. external_id is the idempotency key; a lead without one is keyed on its phone (else email), so re-POSTing the same list updates rather than duplicates.

Request body

json
{
  "properties": {
    "reuse_existing": {
      "type": "boolean",
      "title": "Reuse Existing",
      "default": false
    },
    "campaign_name": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Campaign Name"
    },
    "campaign_id": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Campaign Id"
    },
    "agent_id": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Agent Id"
    },
    "source": {
      "type": "string",
      "title": "Source",
      "default": "api"
    },
    "campaign_type": {
      "type": "string",
      "title": "Campaign Type",
      "default": "qualifier"
    },
    "leads": {
      "items": {
        "properties": {
          "external_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "External Id"
          },
          "full_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Full Name"
          },
          "email": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Email"
          },
          "phone": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Phone"
          },
          "company": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Company"
          },
          "category": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Category"
          },
          "value": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "title": "Value"
          },
          "details": {
            "additionalProperties": true,
            "type": "object",
            "title": "Details"
          },
          "answers": {
            "anyOf": [
              {
                "items": {},
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Answers"
          }
        },
        "type": "object",
        "title": "LeadPayload",
        "description": "One caller-supplied lead (``POST /crm/import/campaign``)."
      },
      "type": "array",
      "title": "Leads"
    },
    "only_with_phone": {
      "type": "boolean",
      "title": "Only With Phone",
      "default": true
    }
  },
  "type": "object",
  "title": "CampaignPayload"
}

200 — Successful Response

json
{
  "additionalProperties": true,
  "type": "object",
  "title": "Response Import Campaign Api V1 Crm Import Campaign Post"
}

422 — Validation Error

json
{
  "properties": {
    "detail": {
      "items": {
        "properties": {
          "loc": {
            "items": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "integer"
                }
              ]
            },
            "type": "array",
            "title": "Location"
          },
          "msg": {
            "type": "string",
            "title": "Message"
          },
          "type": {
            "type": "string",
            "title": "Error Type"
          }
        },
        "type": "object",
        "required": [
          "loc",
          "msg",
          "type"
        ],
        "title": "ValidationError"
      },
      "type": "array",
      "title": "Detail"
    }
  },
  "type": "object",
  "title": "HTTPValidationError"
}

Lubb One Documentation