Skip to main content
POST
/
files
Python
import os
from datagrid_ai import Datagrid

client = Datagrid(
    api_key=os.environ.get("DATAGRID_API_KEY"),  # This is the default and can be omitted
)
file_object = client.files.create(
    file=b"Example data",
)
print(file_object.id)
{
  "object": "file",
  "id": "<string>",
  "filename": "<string>",
  "created_at": "2023-11-07T05:31:56Z",
  "media_type": "<string>",
  "expires_at": "2023-11-07T05:31:56Z",
  "credits": {
    "consumed": 123
  }
}

Documentation Index

Fetch the complete documentation index at: https://developers.datagrid.com/llms.txt

Use this file to discover all available pages before exploring further.

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

multipart/form-data
file
file
required
expires_after
integer | null

The number of seconds after creation when the file will expire and be automatically deleted. Must be a positive integer, maximum 6 days (518400s). If not provided, the file will not expire.

Required range: 1 <= x <= 518400

Response

Successfully created file

The File object represents a document that has been uploaded to Datagrid.

object
enum<string>
required

The object type, which is always file.

Available options:
file
id
string
required

The file identifier, which can be referenced in the API endpoints.

filename
string
required

The name of the file

created_at
string<date-time>
required

The ISO string for when the file was created.

media_type
string
required

The media type of the file.

expires_at
string<date-time> | null

The ISO timestamp when the file will expire and be automatically deleted, or null if the file does not expire.

credits
object

Credit consumption for this file upload. null when the billing lookup fails.