Skip to main content

Datasources API

List All Datasources

tenant_id
string
required
The ID of the tenant
curl -X GET \
  'https://a.messageflow.ai/api/v1/datasources?tenant_id=123' \
  -H 'Authorization: Bearer YOUR_AUTH_TOKEN'
[
  {
    "id": 1,
    "name": "Example Datasource",
    "type": "webpage",
    "url": "https://example.com",
    "status": "active"
  }
]

Get Datasource Details

id
string
required
The ID of the datasource
tenant_id
string
required
The ID of the tenant
curl -X GET \
  'https://a.messageflow.ai/api/v1/datasources/1?tenant_id=123' \
  -H 'Authorization: Bearer YOUR_AUTH_TOKEN'
{
  "id": 1,
  "name": "Example Datasource",
  "type": "webpage",
  "url": "https://example.com",
  "status": "active",
  "content": "Example content...",
  "metadata": {
    "last_updated": "2024-03-20T10:00:00Z",
    "size": "1.2MB"
  },
  "tenant_id": 123
}

Create New Datasource

tenant_id
string
required
The ID of the tenant
datasource[name]
string
required
Name of the datasource
datasource[type]
string
required
Type of datasource
datasource[url]
string
URL for webpage or file datasources
datasource[content]
string
Content for text datasources
datasource[metadata]
object
Additional metadata
curl -X POST \
  'https://a.messageflow.ai/api/v1/datasources?tenant_id=123' \
  -H 'Authorization: Bearer YOUR_AUTH_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
    "datasource": {
      "name": "New Datasource",
      "type": "webpage",
      "url": "https://example.com",
      "metadata": {
        "description": "Example webpage datasource"
      }
    }
  }'
{
  "id": 2,
  "name": "New Datasource",
  "type": "webpage",
  "url": "https://example.com",
  "status": "active",
  "metadata": {
    "description": "Example webpage datasource"
  },
  "tenant_id": 123
}

Update Datasource

id
string
required
The ID of the datasource
tenant_id
string
required
The ID of the tenant
curl -X PUT \
  'https://a.messageflow.ai/api/v1/datasources/1?tenant_id=123' \
  -H 'Authorization: Bearer YOUR_AUTH_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
    "datasource": {
      "name": "Updated Datasource",
      "type": "webpage",
      "url": "https://example.com/updated",
      "metadata": {
        "description": "Updated webpage datasource"
      }
    }
  }'
{
  "id": 1,
  "name": "Updated Datasource",
  "type": "webpage",
  "url": "https://example.com/updated",
  "status": "active",
  "metadata": {
    "description": "Updated webpage datasource"
  },
  "tenant_id": 123
}

Delete Datasource

id
string
required
The ID of the datasource
tenant_id
string
required
The ID of the tenant
curl -X DELETE \
  'https://a.messageflow.ai/api/v1/datasources/1?tenant_id=123' \
  -H 'Authorization: Bearer YOUR_AUTH_TOKEN'
{
  "status": "Datasource 1 deleted"
}

HTTP Status Codes

  • 200: Success
  • 201: Created
  • 400: Bad Request
  • 401: Unauthorized
  • 404: Not Found
  • 422: Unprocessable Entity

Datasource Configuration

The datasource configuration includes:
  • Name and type
  • URL for webpage datasources
  • Content for text datasources
  • Metadata and status
  • Last updated timestamp
  • Size information

Datasource Types

  • Webpage - External web content
  • Text - Direct text content
  • File - Uploaded file content
  • Database - Database connections