> This is Payabli documentation. For a complete page index, fetch https://docs.payabli.com/llms.txt — append .md to any page URL for lightweight markdown. For section-level indexes, query parameters, and other AI-optimized access methods, see https://docs.payabli.com/ai-agents.md

# Upload case attachment

POST https://api-sandbox.payabli.com/api/v2/cases/{caseUuid}/attachments
Content-Type: multipart/form-data

Uploads a file to a case as multipart form data. The maximum size is
25 MiB, and the content type must be an allowed type such as PDF, PNG,
JPEG, CSV, XLSX, DOCX, or plain text.

Available to both Platform and Enterprise Partners.


Reference: https://docs.payabli.com/developers/api-reference/caseManagement/upload-case-attachment

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: payabliApi-oas
  version: 1.0.0
paths:
  /v2/cases/{caseUuid}/attachments:
    post:
      operationId: UploadAttachment
      summary: Upload case attachment
      description: |
        Uploads a file to a case as multipart form data. The maximum size is
        25 MiB, and the content type must be an allowed type such as PDF, PNG,
        JPEG, CSV, XLSX, DOCX, or plain text.

        Available to both Platform and Enterprise Partners.
      tags:
        - caseManagement
      parameters:
        - name: caseUuid
          in: path
          description: The case's UUID.
          required: true
          schema:
            type: string
            format: uuid
      responses:
        '201':
          description: The uploaded attachment
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AttachmentResponse'
        '400':
          description: Bad request / invalid data.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PayabliErrorBody'
        '401':
          description: Unauthorized request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PayabliErrorBody'
        '403':
          description: Consent error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PayabliErrorBody'
        '404':
          description: The case doesn't exist.
          content:
            application/json:
              schema:
                description: Any type
        '500':
          description: Internal server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PayabliErrorBody'
      requestBody:
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                file:
                  type: string
                  format: binary
                  description: The file to upload.
              required:
                - file
servers:
  - url: https://api-sandbox.payabli.com/api
    description: Sandbox
  - url: https://api.payabli.com/api
    description: Production
components:
  schemas:
    UserRef:
      type: object
      properties:
        id:
          type: integer
          format: int64
          description: The user's numeric identifier.
        name:
          type:
            - string
            - 'null'
          description: The user's display name. Null when the name can't be resolved.
      required:
        - id
        - name
      description: A reference to a user, with the display name resolved when available.
      title: UserRef
    AttachmentResponse:
      type: object
      properties:
        uuid:
          type: string
          format: uuid
          description: The attachment's identifier.
        caseUuid:
          type: string
          format: uuid
          description: The case the attachment belongs to.
        fileType:
          type: string
          description: The file's content type.
        filename:
          type: string
          description: The file's name.
        fileUrl:
          type: string
          description: A reference to the stored file.
        uploadedAt:
          type: string
          format: date-time
          description: When the file was uploaded.
        uploadedBy:
          type: string
          description: The id of the user who uploaded the file.
        uploadedByUser:
          oneOf:
            - $ref: '#/components/schemas/UserRef'
            - type: 'null'
          description: The resolved user who uploaded the file. Null when not enriched.
      required:
        - uuid
        - caseUuid
        - fileType
        - filename
        - fileUrl
        - uploadedAt
        - uploadedBy
        - uploadedByUser
      description: A file attached to a case.
      title: AttachmentResponse
    PayabliErrorBodyResponseData:
      type: object
      properties:
        explanation:
          type: string
          description: Human-readable explanation of what happened.
        todoAction:
          type: string
          description: Suggested resolution.
      description: Object with detailed error context.
      title: PayabliErrorBodyResponseData
    PayabliErrorBody:
      type: object
      properties:
        isSuccess:
          type: boolean
          description: Always `false` for error responses.
        responseCode:
          type: integer
          description: |
            Code for the response. Learn more in
            [API Response Codes](/developers/api-reference/api-responses).
        responseText:
          type: string
          description: Error text describing what went wrong.
        responseData:
          $ref: '#/components/schemas/PayabliErrorBodyResponseData'
          description: Object with detailed error context.
      required:
        - isSuccess
        - responseText
      description: |
        Shape returned by every Payabli API error response. The `responseData`
        object carries human-readable error context.
      title: PayabliErrorBody

```

## Examples



**Request**

```json
{
  "file": "<file: string>"
}
```

**Response**

```json
{
  "uuid": "string",
  "caseUuid": "string",
  "fileType": "string",
  "filename": "string",
  "fileUrl": "string",
  "uploadedAt": "2024-01-15T09:30:00Z",
  "uploadedBy": "string",
  "uploadedByUser": {
    "id": 1,
    "name": "string"
  }
}
```

**SDK Code**

```typescript
import { PayabliClient } from "@payabli/sdk-node";

async function main() {
    const client = new PayabliClient();
    await client.caseManagement.uploadAttachment("caseUuid", );
}
main();

```

```python
from payabli import payabli

client = payabli()

client.case_management.upload_attachment(
    case_uuid="caseUuid",
    file="example_file",
)

```

```java
package com.example.usage;

import io.github.payabli.api.PayabliPayabliApiOasClient;
import io.github.payabli.api.resources.casemanagement.requests.UploadAttachmentCaseManagementRequest;

public class Example {
    public static void main(String[] args) {
        PayabliPayabliApiOasClient client = PayabliPayabliApiOasClient
            .builder()
            .build();

        client.caseManagement().uploadAttachment(
            "caseUuid",
            null,
            UploadAttachmentCaseManagementRequest
                .builder()
                .build()
        );
    }
}
```

```csharp
using PayabliPayabliApiOas;
using System.Threading.Tasks;
using System.IO;
using System.Text;

namespace Usage;

public class Example
{
    public async Task Do() {
        var client = new PayabliPayabliApiOasClient();

        await client.CaseManagement.UploadAttachmentAsync(
            "caseUuid",
            new UploadAttachmentCaseManagementRequest {
                File = new FileParameter(){
                    Stream = new MemoryStream(Encoding.UTF8.GetBytes("[bytes]"))
                }
            }
        );
    }

}

```

```go
package example

import (
    context "context"
    strings "strings"

    payabli "github.com/payabli/sdk-go"
    client "github.com/payabli/sdk-go/client"
)

func do() {
    client := client.NewClient()
    request := &payabli.UploadAttachmentCaseManagementRequest{
        File: strings.NewReader(
            "",
        ),
    }
    client.CaseManagement.UploadAttachment(
        context.TODO(),
        "caseUuid",
        request,
    )
}

```

```php
<?php

namespace Example;

use Payabli\PayabliClient;
use Payabli\CaseManagement\Requests\UploadAttachmentCaseManagementRequest;
use Payabli\Utils\File;

$client = new PayabliClient();
$client->caseManagement->uploadAttachment(
    'caseUuid',
    new UploadAttachmentCaseManagementRequest([
        'file' => File::createFromString("example_file", "example_file"),
    ]),
);

```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api-sandbox.payabli.com/api/v2/cases/caseUuid/attachments")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'multipart/form-data; boundary=---011000010111000001101001'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"string\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001--\r\n"

response = http.request(request)
puts response.read_body
```

```swift
import Foundation

let headers = ["Content-Type": "multipart/form-data; boundary=---011000010111000001101001"]
let parameters = [
  [
    "name": "file",
    "fileName": "string"
  ]
]

let boundary = "---011000010111000001101001"

var body = ""
var error: NSError? = nil
for param in parameters {
  let paramName = param["name"]!
  body += "--\(boundary)\r\n"
  body += "Content-Disposition:form-data; name=\"\(paramName)\""
  if let filename = param["fileName"] {
    let contentType = param["content-type"]!
    let fileContent = String(contentsOfFile: filename, encoding: String.Encoding.utf8)
    if (error != nil) {
      print(error as Any)
    }
    body += "; filename=\"\(filename)\"\r\n"
    body += "Content-Type: \(contentType)\r\n\r\n"
    body += fileContent
  } else if let paramValue = param["value"] {
    body += "\r\n\r\n\(paramValue)"
  }
}

let request = NSMutableURLRequest(url: NSURL(string: "https://api-sandbox.payabli.com/api/v2/cases/caseUuid/attachments")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```