Skip to main content

PATCH /api/documents//rename

Updates the filename of an existing document. This only changes the stored filename metadata, not the physical file on disk.

Authentication

This endpoint requires authentication using Laravel Sanctum. Include the bearer token in the Authorization header.

Path parameters

id
integer
required
The ID of the document to rename

Headers

Authorization
string
required
Bearer token obtained from login endpoint
Content-Type
string
required
Set to application/json
Accept
string
Set to application/json

Body parameters

filename
string
required
The new filename for the documentValidation rules:
  • Required
  • Must be a string
  • Maximum length: 255 characters

Authorization

Users can only rename their own documents. Attempting to rename another user’s document will return a 404 error.

Response

Returns a success message and the updated document object.
message
string
Success message confirming the rename operation
document
object
The updated document object
document.id
integer
Unique identifier for the document
document.user_id
integer
ID of the user who owns the document
document.filename
string
Updated filename of the document
document.mime_type
string
MIME type of the document
document.path
string
Storage path of the document file (unchanged)
document.status
string
Processing status of the document
document.vector_id
string
ID of the vector representation in the vector database
document.created_at
string
ISO 8601 timestamp when the document was created
document.updated_at
string
ISO 8601 timestamp when the document was last updated
Renaming a document only updates the filename metadata. The physical file path and storage location remain unchanged.

Example request

curl -X PATCH https://api.filebright.com/api/documents/1/rename \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -d '{"filename": "updated-contract.pdf"}'

Example response

200 - Success
{
  "message": "Document renamed successfully",
  "document": {
    "id": 1,
    "user_id": 42,
    "filename": "updated-contract.pdf",
    "mime_type": "application/pdf",
    "path": "documents/9a8b7c6d5e4f3g2h1i.pdf",
    "status": "completed",
    "vector_id": "vec_xyz789",
    "created_at": "2026-03-01T10:30:00.000000Z",
    "updated_at": "2026-03-03T16:20:45.000000Z"
  }
}
401 - Unauthorized
{
  "message": "Unauthenticated."
}
404 - Not found
{
  "message": "Document not found"
}
422 - Validation error
{
  "message": "The filename field is required.",
  "errors": {
    "filename": [
      "The filename field is required."
    ]
  }
}
422 - Filename too long
{
  "message": "The filename must not be greater than 255 characters.",
  "errors": {
    "filename": [
      "The filename must not be greater than 255 characters."
    ]
  }
}

Build docs developers (and LLMs) love