Attachments and Files

Create New Attachment (Integration)

POST /api/attachments-upload/

Code Examples

# API Call Example (Shell)
curl -X POST "https://api.maiagent.ai/api/attachments-upload/" \
  -H "Authorization: Api-Key YOUR_API_KEY" \
  -F "file=@example_file.pdf"

# Please replace YOUR_API_KEY and verify the request data before execution.

Response Body

Status Code
Description

200

No response body


Get a Pre-signed URL for File Upload (Create/Get)

POST /api/upload-presigned-url/

Parameters

Parameter Name
Required
Type
Description

fieldName

string

Field Name

filename

string

File Name

modelName

string

Model Name

Request Body

Request Parameters

Field
Type
Required
Description

fileSize

integer

Yes

Request Structure Example

{
  "fileSize": integer
}

Request Example Value

{
  "fileSize": 123
}

Code Examples

# Call API Example (Shell)
curl -X POST "https://api.maiagent.ai/api/upload-presigned-url/?fieldName=example&filename=example&modelName=example" \
  -H "Authorization: Api-Key YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "modelName": "example string",
    "fieldName": "example string",
    "filename": "document.pdf",
    "fileSize": 123
  }'

# Please replace YOUR_API_KEY and verify the request data before execution.

Response Body

Status Code: 200

Response Schema Example

{
  "url": string (uri) // URL of the S3 bucket
  "fields": object // Form fields for the POST request
}

Response Example Value

{
  "url": "https://s3.example.com/bucket-name",
  "fields": {
    "key": "media/chat/attachment/filename.pdf",
    "x-amz-algorithm": "AWS4-HMAC-SHA256",
    "x-amz-credential": "AKIAXXXXXXXXXXXXXXXX/YYYYMMDD/region/s3/aws4_request",
    "x-amz-date": "YYYYMMDDTHHMMSSZ",
    "policy": "base64-encoded-policy-document",
    "x-amz-signature": "generated-signature-hash"
  }
}

Presigned Attachment Upload

POST /api/attachments/

Request Body

Request Parameters

Field
Type
Required
Description

type

object

No

filename

string

Yes

file

string (uri)

Yes

Request Structure Example

{
  "type"?:  // optional
  {
  }
  "filename": string
  "file": string (uri)
}

Request Example Value

{
  "type": {},
  "filename": "document.pdf",
  "file": "https://example.com/file.jpg"
}

Code Examples

# Call API Example (Shell)
curl -X POST "https://api.maiagent.ai/api/attachments/" \
  -H "Authorization: Api-Key YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "type": {},
    "filename": "document.pdf",
    "file": "https://example.com/file.jpg"
  }'

# Please make sure to replace YOUR_API_KEY and verify the request data before execution.

Response Body

Status Code: 201

Response Schema Example

{
  "id": string (uuid)
  "type"?:  // Optional
  {
  }
  "filename": string
  "file": string (uri)
}

Response Example Value

{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "type": {},
  "filename": "Response String",
  "file": "https://example.com/file.jpg"
}

Create Conversation Attachment

POST /api/conversations/{conversationPk}/attachments/

Parameters

Parameter Name
Required
Type
Description

conversationPk

string

Request Body

Request Parameters

Field
Type
Required
Description

type

object

No

filename

string

Yes

file

string (uri)

Yes

conversation

string (uuid)

No

Request Structure Example

{
  "type"?:  // optional
  {
  }
  "filename": string
  "file": string (uri)
  "conversation"?: string (uuid) // optional
}

Request Example Value

{
  "type": {},
  "filename": "document.pdf",
  "file": "https://example.com/file.jpg",
  "conversation": "550e8400-e29b-41d4-a716-446655440000"
}

Code Examples

# Call API Example (Shell)
curl -X POST "https://api.maiagent.ai/api/conversations/{conversationPk}/attachments/" \
  -H "Authorization: Api-Key YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "type": {},
    "filename": "document.pdf",
    "file": "https://example.com/file.jpg",
    "conversation": "550e8400-e29b-41d4-a716-446655440000"
  }'

# Please replace YOUR_API_KEY and verify the request data before execution.

Response Body

Status Code: 201

Response Schema Example

{
  "id": string (uuid)
  "type"?:  // Optional
  {
  }
  "filename": string
  "file": string (uri)
  "conversation"?: string (uuid) // Optional
}

Response Example Value

{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "type": {},
  "filename": "response string",
  "file": "https://example.com/file.jpg",
  "conversation": "550e8400-e29b-41d4-a716-446655440000"
}

Last updated

Was this helpful?