# Data ## Add `data.add(strnamespace, DataAddParams**kwargs) -> DataAddResponse` **post** `/v1/data/{namespace}` Add data to a namespace. This method returns immediately; data is processed asynchronously. ### Parameters - `namespace: str` The namespace to ingest data into - `data: Data` A data object to ingest. Must have an id field. All other fields are flexible and can any JSON types. - `class DataDataObject: …` A data object to ingest. Must have an id field. All other fields are flexible and can any JSON types. - `id: str` Unique identifier for this data object. This should be a meaningful identifier in the customer's system, as it is the main way to search for specific items between systems. - `Iterable[DataDataObjectArray]` Array of data objects to ingest. - `id: str` Unique identifier for this data object. This should be a meaningful identifier in the customer's system, as it is the main way to search for specific items between systems. ### Returns - `class DataAddResponse: …` Response confirming data was accepted for asynchronous processing. The requestId can be used for debugging and tracking. - `request_id: str` Unique identifier for tracking this request. Data processing happens asynchronously after this response. - `status: Literal["accepted"]` Request was accepted for processing - `"accepted"` ### Example ```python import os from safetykit import Safetykit client = Safetykit( api_key=os.environ.get("SAFETYKIT_API_KEY"), # This is the default and can be omitted ) response = client.data.add( namespace="namespace", data={ "id": "user-12345" }, ) print(response.request_id) ``` ## Import `data.import_(strnamespace) -> DataImportResponse` **post** `/v1/data/{namespace}/import` Request a pre-signed upload URL for importing large JSONL batches into a namespace. After receiving `upload_url`, upload your JSONL file using `PUT {upload_url}` with header `Content-Type: application/json`; put each JSON object on a new line. ### Parameters - `namespace: str` The namespace to ingest data into ### Returns - `class DataImportResponse: …` Response containing an upload URL and metadata for large-batch import processing. Use `PUT {upload_url}` to upload JSONL (one JSON object per line). `upload_url` expires in 12 hours. - `expires_at: str` ISO timestamp when upload_url expires (12 hours after issuance) - `object_key: str` S3 object key where uploaded JSONL will be processed from - `request_id: str` Unique identifier for this import request - `status: Literal["pending_upload"]` Import request is waiting for file upload - `"pending_upload"` - `upload_url: str` Pre-signed upload URL for PUT-ing JSONL content (`Content-Type: application/json`) ### Example ```python import os from safetykit import Safetykit client = Safetykit( api_key=os.environ.get("SAFETYKIT_API_KEY"), # This is the default and can be omitted ) response = client.data.import_( "namespace", ) print(response.expires_at) ``` ## Get Status `data.get_status(strrequest_id, DataGetStatusParams**kwargs) -> DataGetStatusResponse` **get** `/v1/data/{namespace}/requests/{requestId}` Retrieve status on data ingestion request. Supports both add and import requests. ### Parameters - `namespace: str` The namespace the data was ingested into - `request_id: str` The request ID returned from the Add endpoint ### Returns - `DataGetStatusResponse` Response containing request status and processed output data. - `class DataGetRequestAddOutput: …` - `data: List[DataGetRequestAddOutputData]` - `id: str` Object identifier from the ingested data - `output: Optional[DataGetRequestAddOutputDataOutput]` - `actions: List[Optional[object]]` - `fields: Dict[str, Optional[object]]` - `labels: List[DataGetRequestAddOutputDataOutputLabel]` - `label: str` - `url: str` - `metadata: Optional[Dict[str, Optional[object]]]` - `namespace: str` - `request_id: str` - `status: Literal["queued", "uploading", "ingesting", 2 more]` Current processing status of the request - `"queued"` - `"uploading"` - `"ingesting"` - `"succeeded"` - `"failed"` - `class DataGetRequestImportOutput: …` - `data_count: int` - `data_expires_at: str` - `data_url: str` - `namespace: str` - `request_id: str` - `status: Literal["queued", "uploading", "ingesting", 2 more]` Current processing status of the request - `"queued"` - `"uploading"` - `"ingesting"` - `"succeeded"` - `"failed"` ### Example ```python import os from safetykit import Safetykit client = Safetykit( api_key=os.environ.get("SAFETYKIT_API_KEY"), # This is the default and can be omitted ) response = client.data.get_status( request_id="requestId", namespace="namespace", ) print(response) ``` ## Update Settings `data.update_settings(strnamespace, DataUpdateSettingsParams**kwargs) -> DataUpdateSettingsResponse` **put** `/v1/data/{namespace}/settings` Create or replace settings for a namespace, primarily used to change the schema associated with the namespace. ### Parameters - `namespace: str` The namespace to ingest data into - `schema: Dict[str, Schema]` Schema mapping field names to their definitions. Use content_type to specify which fields contain URLs that should be processed (images, videos, or websites), datetime fields, or 'metadata' for fields that should be stored but not indexed. Use display_hint to provide UI rendering hints. - `content_type: Optional[Literal["image_url", "video_url", "website_url", 2 more]]` The type of content (image_url, video_url, website_url, datetime, or metadata). When specified as a URL type, SafetyKit will process the URL. Use 'metadata' for fields that should be stored but not indexed. - `"image_url"` - `"video_url"` - `"website_url"` - `"datetime"` - `"metadata"` - `display_hint: Optional[SchemaDisplayHint]` Display hint for UI rendering of this field - `type: Literal["title", "subtitle", "description", 13 more]` The display hint type - `"title"` - `"subtitle"` - `"description"` - `"primary_image_url"` - `"video_url"` - `"location"` - `"compact_text"` - `"markdown"` - `"html"` - `"email.reply_to"` - `"email.body"` - `"email.subject"` - `"email.body_image"` - `"email.logo_image"` - `"email.event"` - `"email.footer"` - `field_limit: Optional[int]` Maximum amount of this field to include when sending to AI models. For text fields, this is the character limit. For array fields (e.g. image URLs), this is the maximum number of items. - `namespace_ref: Optional[str]` The namespace which an id refers to, creating a parent-child relationship with that namespace. ### Returns - `class DataUpdateSettingsResponse: …` Namespace configuration was stored. - `namespace: str` - `status: Literal["updated"]` - `"updated"` ### Example ```python import os from safetykit import Safetykit client = Safetykit( api_key=os.environ.get("SAFETYKIT_API_KEY"), # This is the default and can be omitted ) response = client.data.update_settings( namespace="namespace", schema={ "profile_image": {}, "cover_photo": {}, "website": {}, }, ) print(response.namespace) ```