-
Notifications
You must be signed in to change notification settings - Fork 13
500 error when activating draft schema for existing active object type #3
Description
Summary
PATCH /api/object-schemas/{id} with status: ACTIVE returns a 500 server error when activating a draft schema that was created via POST /api/object-schemas for an object type that already has an active schema. This blocks updating custom object schemas with new properties.
Steps to reproduce
All requests use revision: 2026-01-15.pre.
1. Create an object type with an initial schema (works)
curl -X POST https://a.klaviyo.com/api/object-types \
-H 'Authorization: Klaviyo-API-Key <KEY>' \
-H 'content-type: application/vnd.api+json' \
-H 'revision: 2026-01-15.pre' \
-d '{
"data": {
"type": "object-type",
"attributes": {
"title": "TestObject",
"description": "Test",
"object-schema": {
"data": {
"type": "object-schema",
"attributes": {
"properties": [
{"id": 1, "name": "field_a", "type": "STRING"}
]
}
}
}
}
}
}'Note the draft-schema ID from the response relationships.
2. Set up profile relationship, source mapping, and activate (works)
# Create profile relationship
curl -X POST https://a.klaviyo.com/api/object-schemas/<DRAFT_SCHEMA_ID>/relationships/profile-object-schemas \
-H 'Authorization: Klaviyo-API-Key <KEY>' \
-H 'content-type: application/vnd.api+json' \
-H 'revision: 2026-01-15.pre' \
-d '{"data": [{"type": "profile-object-schema", "id": "profile", "meta": {"name": "test_owner"}}]}'
# Configure source mapping (with matching property + relationship mappings)
curl -X PATCH https://a.klaviyo.com/api/source-mappings/<DRAFT_SCHEMA_ID> \
-H 'Authorization: Klaviyo-API-Key <KEY>' \
-H 'content-type: application/vnd.api+json' \
-H 'revision: 2026-01-15.pre' \
-d '{ ... property_mappings + relationship_mappings ... }'
# Activate — this works for the initial schema
curl -X PATCH https://a.klaviyo.com/api/object-schemas/<DRAFT_SCHEMA_ID> \
-H 'Authorization: Klaviyo-API-Key <KEY>' \
-H 'content-type: application/vnd.api+json' \
-H 'revision: 2026-01-15.pre' \
-d '{"data": {"type": "object-schema", "id": "<DRAFT_SCHEMA_ID>", "attributes": {"status": "ACTIVE"}}}'3. Create a new draft schema for the now-active object type (works)
curl -X POST https://a.klaviyo.com/api/object-schemas \
-H 'Authorization: Klaviyo-API-Key <KEY>' \
-H 'content-type: application/vnd.api+json' \
-H 'revision: 2026-01-15.pre' \
-d '{
"data": {
"type": "object-schema",
"attributes": {
"title": "TestObject",
"properties": [
{"id": 1, "name": "field_a", "type": "STRING"},
{"id": 2, "name": "field_b", "type": "STRING"}
]
},
"relationships": {
"object-type": {
"data": {"type": "object-type", "id": "<OBJECT_TYPE_ID>"}
}
}
}
}'This returns 201 with a new draft schema ID.
4. Set up profile relationship, source mapping on the new draft (works)
Profile relationship is created, source mapping is configured with 1:1 property and relationship mappings. Verified via GET that everything matches.
5. Activate the new draft (FAILS with 500)
curl -X PATCH https://a.klaviyo.com/api/object-schemas/<NEW_DRAFT_SCHEMA_ID> \
-H 'Authorization: Klaviyo-API-Key <KEY>' \
-H 'content-type: application/vnd.api+json' \
-H 'revision: 2026-01-15.pre' \
-d '{"data": {"type": "object-schema", "id": "<NEW_DRAFT_SCHEMA_ID>", "attributes": {"status": "ACTIVE"}}}'Response: 500
{
"errors": [{
"status": 500,
"code": "error",
"title": "A server error occurred.",
"detail": "A server error occurred.",
"source": {"pointer": "/data/"}
}]
}Verified state before activation
Before the failing activation call, I verified via GET:
- Schema (
GET /api/object-schemas/<ID>): statusDRAFT, all properties present,published_at: null - Source mapping (
GET /api/source-mappings/<ID>): allproperty_mappingshave matching IDs,relationship_mappingsreference the correctrelationship_id - Profile relationship (
GET /api/object-schemas/<ID>?include=profile-object-schemas): included with correctrelationship_idin meta
Everything is correctly configured per the docs. The 500 is consistently reproducible across multiple attempts.
Expected behavior
The draft schema should transition to PUBLISHING then ACTIVE, replacing the previous active schema version — the same way it works for the initial activation in step 2.
Environment
- API revision:
2026-01-15.pre - Node SDK:
klaviyo-apinpm package - Response time on 500: ~1300ms (suggests server-side processing before failure)