civis.io.json_to_file

civis.io.json_to_file(obj, name: str | None = 'file.json', expires_at: str | None = 'DEFAULT', description: str | None = None, client: APIClient | None = None, **json_kwargs) int[source]

Store a JSON-serializable object in a Civis File

Parameters:
obj

The object to be JSON-serialized and stored in a Civis File

namestr, optional

The name of the Civis File

expires_atstr, optional

The date and time the file will expire. If not specified, the file will expire in 30 days. To specify a date and time, format it by the ISO 8601 standard (e.g., "2020-12-31", "2020-12-31T23:03:40Z"), or equivalently, the returned value of the isoformat() method from a datetime.date or datetime.datetime object. To keep a file indefinitely, specify None.

descriptionstr, optional

Description (max length: 512 characters) of the file object.

clientcivis.APIClient, optional

If not provided, an civis.APIClient object will be created from the CIVIS_API_KEY.

**json_kwargs

Additional keyword arguments will be passed directly to json.dump().

Returns:
file_idint

The integer ID of the new Civis File object

Raises:
ValueError

If description is provided and it’s longer than 512 characters.