Api Temporary Keys Update

Stamp server-controlled fields at save time — never by mutating ``request.data``. DRF's contract: ``post()`` → ``create()`` → ``serializer.is_valid()`` → ``perform_create(serializer)`` → ``serializer.save(**kwargs)``. Server values belong in that final ``save(**kwargs)`` — they override ``validated_data``, never pass through client validation, and don't need to be *writable* serializer fields. The matching serializer field becomes ``read_only=True`` (or is dropped from ``fields``), shrinking — not widening — the mass-assignment surface, and the immutable-``QueryDict`` (multipart) failure mode of the old ``request.data[...] =`` pattern disappears. Declare the fields to stamp as ``field -> fn(view) -> value`` maps:: class ExperimentV2sView(ServerStampedFieldsMixin, ...): create_stamped_fields = {"created_by": stamp_request_user_id} # + serializer: created_by = ...(read_only=True) FK columns: when the stamped value is an ``int`` and the field names a relation on the serializer's ``Meta.model``, the kwarg is rewritten to ``<field>_id`` so ``Model.objects.create`` accepts it (a raw ``int`` on the FK attribute itself would raise). Non-relation fields (``scorer`` = email) and instance values pass through unchanged. Cooperative composition: subclasses that need to stamp *additional* server values (e.g. ``OrganizationInjectionMixin`` stamping org/project) override ``get_create_save_kwargs`` / ``get_update_save_kwargs`` and merge onto ``super()`` — yielding exactly ONE ``serializer.save()`` per request (calling ``save()`` twice would re-run create/update side effects).

Authentication

AuthorizationBearer
JWT access token or Respan API key

Path parameters

idstringRequired

Request

This endpoint expects an object.
projectstring or nullOptional>=1 character
namestringOptional1-50 characters

A free-form name for the API key. Need not be unique. 50 characters max.

revokedbooleanOptional

If the API key is revoked, clients cannot use it anymore. (This cannot be undone.)

expiry_datedatetime or nullOptional
Once API key expires, clients cannot use it anymore.
max_usageintegerOptional-2147483648-2147483647
rate_limitdouble or nullOptional
spending_limitdouble or nullOptional
is_temporarybooleanOptional

Response

idstringRead-only
api_keystringRead-only
suffixstringRead-only
tagslist of objectsRead-only
statusenum
  • active - Active
  • expired - Expired
  • revoked - Revoked
prefixstringRead-only
hashed_keystringRead-only
createddatetimeRead-only
key_usageintegerRead-only
last_useddatetimeRead-only
spending_in_perioddoubleRead-only
is_testbooleanRead-only
revoked_atdatetime or nullRead-only
revoked_by_emailstring or nullRead-only
userinteger or nullRead-only
organizationinteger or nullRead-only
created_byinteger or nullRead-only
updated_byinteger or nullRead-only
projectstring or null
namestring<=50 characters

A free-form name for the API key. Need not be unique. 50 characters max.

revokedboolean

If the API key is revoked, clients cannot use it anymore. (This cannot be undone.)

expiry_datedatetime or null
Once API key expires, clients cannot use it anymore.
max_usageinteger-2147483648-2147483647
rate_limitdouble or null
spending_limitdouble or null
is_temporaryboolean