{
  "openapi": "3.1.0",
  "info": {
    "title": "TeleCRM API",
    "version": "v1",
    "description": "TeleCRM APIs help calling teams manage lead lists, call outcomes, callbacks, agent assignment, and daily calling performance.",
    "contact": {
      "name": "Azeosoft Web Technologies",
      "url": "https://azeosoft.com"
    }
  },
  "servers": [
    {
      "url": "https://api-telecrm.azeosoft.com/v1",
      "description": "Production"
    }
  ],
  "tags": [
    {
      "name": "Authentication",
      "description": "Authenticate and verify access for TeleCRM integrations."
    },
    {
      "name": "Calling Leads",
      "description": "Create, read, update, and list calling leads in TeleCRM."
    },
    {
      "name": "Callbacks",
      "description": "Manage callbacks workflows in TeleCRM."
    },
    {
      "name": "Reports",
      "description": "Export TeleCRM analytics and operational summaries."
    }
  ],
  "paths": {
    "/auth/token": {
      "post": {
        "operationId": "telecrm-token",
        "summary": "Create access token",
        "description": "Creates a short-lived access token for TeleCRM API requests.",
        "tags": [
          "Authentication"
        ],
        "parameters": [],
        "responses": {
          "200": {
            "description": "Access token returned",
            "content": {
              "application/json": {
                "example": {
                  "data": {
                    "access_token": "az_live_token",
                    "token_type": "Bearer",
                    "expires_in": 3600
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "description": "Client credentials issued from the product admin panel.",
          "required": true,
          "content": {
            "application/json": {
              "example": {
                "client_id": "telecrm_client",
                "client_secret": "********"
              }
            }
          }
        }
      }
    },
    "/auth/profile": {
      "get": {
        "operationId": "telecrm-profile",
        "summary": "Get integration profile",
        "description": "Returns organization and permission details for the authenticated TeleCRM integration.",
        "tags": [
          "Authentication"
        ],
        "parameters": [],
        "responses": {
          "200": {
            "description": "Integration profile returned",
            "content": {
              "application/json": {
                "example": {
                  "data": {
                    "organizationId": "org_001",
                    "product": "TeleCRM",
                    "scopes": [
                      "read",
                      "write"
                    ]
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ]
      }
    },
    "/calling-leads": {
      "get": {
        "operationId": "telecrm-list-records",
        "summary": "List calling leads",
        "description": "Returns a paginated list of calling leads for the organization.",
        "tags": [
          "Calling Leads"
        ],
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Maximum records to return.",
            "schema": {
              "type": "integer"
            },
            "example": "50"
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "Pagination cursor from the previous response.",
            "schema": {
              "type": "string"
            },
            "example": "next_abc123"
          }
        ],
        "responses": {
          "200": {
            "description": "Calling Leads list returned",
            "content": {
              "application/json": {
                "example": {
                  "data": {
                    "items": [
                      {
                        "id": "calling_lead_id_001",
                        "name": "Priya Mehta",
                        "phone": "+918888888888",
                        "campaign": "July Renewals",
                        "disposition": "new"
                      }
                    ],
                    "nextCursor": null
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ]
      },
      "post": {
        "operationId": "telecrm-create-record",
        "summary": "Create calling leads",
        "description": "Creates a new calling leads record.",
        "tags": [
          "Calling Leads"
        ],
        "parameters": [],
        "responses": {
          "201": {
            "description": "Calling Leads created",
            "content": {
              "application/json": {
                "example": {
                  "data": {
                    "id": "calling_lead_id_001",
                    "name": "Priya Mehta",
                    "phone": "+918888888888",
                    "campaign": "July Renewals",
                    "disposition": "new",
                    "created_at": "2026-07-26T09:00:00Z"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "description": "Calling Leads fields.",
          "required": true,
          "content": {
            "application/json": {
              "example": {
                "name": "Priya Mehta",
                "phone": "+918888888888",
                "campaign": "July Renewals",
                "disposition": "new"
              }
            }
          }
        }
      }
    },
    "/calling-leads/{calling_lead_id}": {
      "get": {
        "operationId": "telecrm-get-record",
        "summary": "Get calling leads details",
        "description": "Returns details for a specific calling leads record.",
        "tags": [
          "Calling Leads"
        ],
        "parameters": [
          {
            "name": "calling_lead_id",
            "in": "path",
            "required": true,
            "description": "Calling Leads ID.",
            "schema": {
              "type": "string"
            },
            "example": "calling_lead_id_001"
          }
        ],
        "responses": {
          "200": {
            "description": "Calling Leads details returned",
            "content": {
              "application/json": {
                "example": {
                  "data": {
                    "id": "calling_lead_id_001",
                    "name": "Priya Mehta",
                    "phone": "+918888888888",
                    "campaign": "July Renewals",
                    "disposition": "new"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ]
      },
      "patch": {
        "operationId": "telecrm-update-record",
        "summary": "Update calling leads",
        "description": "Updates selected fields on a calling leads record.",
        "tags": [
          "Calling Leads"
        ],
        "parameters": [
          {
            "name": "calling_lead_id",
            "in": "path",
            "required": true,
            "description": "Calling Leads ID.",
            "schema": {
              "type": "string"
            },
            "example": "calling_lead_id_001"
          }
        ],
        "responses": {
          "200": {
            "description": "Calling Leads updated",
            "content": {
              "application/json": {
                "example": {
                  "data": {
                    "id": "calling_lead_id_001",
                    "status": "active",
                    "updated_at": "2026-07-26T10:00:00Z"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "description": "Partial Calling Leads fields.",
          "required": true,
          "content": {
            "application/json": {
              "example": {
                "status": "active"
              }
            }
          }
        }
      }
    },
    "/callbacks": {
      "get": {
        "operationId": "telecrm-workflow-list",
        "summary": "List callbacks",
        "description": "Returns workflow records used by TeleCRM.",
        "tags": [
          "Callbacks"
        ],
        "parameters": [],
        "responses": {
          "200": {
            "description": "Callbacks returned",
            "content": {
              "application/json": {
                "example": {
                  "data": {
                    "items": [
                      {
                        "id": "flow_001",
                        "name": "Callbacks",
                        "status": "active"
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ]
      }
    },
    "/callbacks/actions": {
      "post": {
        "operationId": "telecrm-workflow-action",
        "summary": "Create callbacks action",
        "description": "Creates an operational action inside the callbacks workflow.",
        "tags": [
          "Callbacks"
        ],
        "parameters": [],
        "responses": {
          "201": {
            "description": "Workflow action created",
            "content": {
              "application/json": {
                "example": {
                  "data": {
                    "actionId": "act_001",
                    "status": "queued"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "description": "Workflow action payload.",
          "required": true,
          "content": {
            "application/json": {
              "example": {
                "target_id": "calling_lead_id_001",
                "action": "assign",
                "owner_id": "user_001",
                "note": "Assigned from API"
              }
            }
          }
        }
      }
    },
    "/reports/calling-performance": {
      "get": {
        "operationId": "telecrm-summary-report",
        "summary": "Calling performance report",
        "description": "Returns the calling performance report for a selected date range.",
        "tags": [
          "Reports"
        ],
        "parameters": [
          {
            "name": "from",
            "in": "query",
            "required": true,
            "description": "Start date in YYYY-MM-DD format.",
            "schema": {
              "type": "string"
            },
            "example": "2026-07-01"
          },
          {
            "name": "to",
            "in": "query",
            "required": true,
            "description": "End date in YYYY-MM-DD format.",
            "schema": {
              "type": "string"
            },
            "example": "2026-07-26"
          }
        ],
        "responses": {
          "200": {
            "description": "Report returned",
            "content": {
              "application/json": {
                "example": {
                  "data": {
                    "from": "2026-07-01",
                    "to": "2026-07-26",
                    "totals": {
                      "records": 128,
                      "open": 18,
                      "closed": 110
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ]
      }
    },
    "/reports/calling-performance/export": {
      "post": {
        "operationId": "telecrm-export-report",
        "summary": "Export report",
        "description": "Creates a downloadable TeleCRM report export.",
        "tags": [
          "Reports"
        ],
        "parameters": [],
        "responses": {
          "202": {
            "description": "Export queued",
            "content": {
              "application/json": {
                "example": {
                  "data": {
                    "exportId": "exp_001",
                    "status": "processing"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "description": "Export options.",
          "required": true,
          "content": {
            "application/json": {
              "example": {
                "format": "csv",
                "from": "2026-07-01",
                "to": "2026-07-26"
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT"
      },
      "apiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "x-api-key"
      }
    }
  }
}
