# Upload ## Initiate a dataset upload `client.datasets.upload.initiate(UploadInitiateParamsbody, RequestOptionsoptions?): UploadInitiateResponse` **post** `/api/v1/datasets/upload/initiate` Initiate a dataset upload ### Parameters - `body: UploadInitiateParams` - `file_format: "csv" | "json" | "jsonl" | "parquet"` Format of the file being uploaded - `"csv"` - `"json"` - `"jsonl"` - `"parquet"` - `name: string` Human-readable name for the dataset ### Returns - `UploadInitiateResponse` - `upload_url: string` Pre-signed S3 URL — upload the file directly to this URL via HTTP PUT ### Example ```typescript import Adaption from 'adaption'; const client = new Adaption({ apiKey: process.env['ADAPTION_API_KEY'], // This is the default and can be omitted }); const response = await client.datasets.upload.initiate({ file_format: 'csv', name: 'my-training-data', }); console.log(response.upload_url); ``` #### Response ```json { "upload_url": "https://s3.amazonaws.com/bucket/key?X-Amz-Signature=..." } ``` ## Complete a dataset upload and trigger processing `client.datasets.upload.complete(UploadCompleteParamsbody, RequestOptionsoptions?): UploadCompleteResponse` **post** `/api/v1/datasets/upload/complete` Complete a dataset upload and trigger processing ### Parameters - `body: UploadCompleteParams` - `file_format: "csv" | "json" | "jsonl" | "parquet"` Format of the uploaded file - `"csv"` - `"json"` - `"jsonl"` - `"parquet"` - `file_size_bytes: number` Size of the uploaded file in bytes - `name: string` Human-readable name for the dataset - `s3_key: string` S3 object key returned in the pre-signed URL response from /upload/initiate ### Returns - `UploadCompleteResponse` - `dataset_id: string` ID of the newly created dataset ### Example ```typescript import Adaption from 'adaption'; const client = new Adaption({ apiKey: process.env['ADAPTION_API_KEY'], // This is the default and can be omitted }); const response = await client.datasets.upload.complete({ file_format: 'csv', file_size_bytes: 1048576, name: 'my-training-data', s3_key: 'uploads/550e8400-e29b-41d4-a716-446655440000/my-training-data.csv', }); console.log(response.dataset_id); ``` #### Response ```json { "dataset_id": "550e8400-e29b-41d4-a716-446655440000" } ``` ## Complete a file upload and trigger processing `client.datasets.upload.completeByID(stringdatasetID, UploadCompleteByIDParamsbody, RequestOptionsoptions?): UploadCompleteByIDResponse` **post** `/api/v1/datasets/{dataset_id}/upload/complete` File uploads only. Call after uploading bytes to the presigned URL from POST /datasets. Verifies the file exists in S3, then triggers the preprocessing pipeline. ### Parameters - `datasetID: string` - `body: UploadCompleteByIDParams` - `file_size_bytes: number` Size of the uploaded file in bytes (for verification) - `sha256?: string` SHA-256 hex digest of the uploaded file (for integrity verification) ### Returns - `UploadCompleteByIDResponse` - `dataset_id: string` ID of the dataset - `status: string` Current status of the dataset after completing upload ### Example ```typescript import Adaption from 'adaption'; const client = new Adaption({ apiKey: process.env['ADAPTION_API_KEY'], // This is the default and can be omitted }); const response = await client.datasets.upload.completeByID('dataset_id', { file_size_bytes: 1048576, }); console.log(response.dataset_id); ``` #### Response ```json { "dataset_id": "550e8400-e29b-41d4-a716-446655440000", "status": "processing" } ```