---
title: "Update Metadata Schema"
method: PUT
path: "/management/v1/projects/{projectId}/metadata-schemas/{metadataSchemaId}"
tags: ["Management"]
---

# Update Metadata Schema

`PUT /management/v1/projects/{projectId}/metadata-schemas/{metadataSchemaId}`

Updates a metadata schema.

With this request, you can:
- Add a nonexistent attribute definition to the metadata schema.
- Update an existing attribute definition by overwriting its current values.

In the request, you can provide only those definitions you want to add or update. Definitions omitted in the request remain unchanged.

However, if you want to update a definition, you will have to add all its current key-value pairs as well. Only the pairs sent in the request are saved for this definition. This means that the key-value pairs that are not sent in a request are restored to default values. For example, if your definition has an array with values and it is not sent in an update request, the array values will be deleted.

> 👍 Additional Notes
>
>- You cannot change the type of an existing schema, e.g. from `"string"` to `"number"`.
>
>- You can remove a definition with this endpoint by providing `"deleted": true` in the request. It will be moved to the Removed definitions section in the user interface. However, you cannot permanently remove a definition with this endpoint.

> 📘 Metadata Documentation
>
> Read [the Getting Started with Metadata](/prepare/metadata) and [Metadata Mapping](/guides/metadata-mapping) articles to learn how metadata work in Voucherify.

## Request body

- ManagementProjectsMetadataSchemasUpdateRequestBody
  - `allow_defined_only` boolean — Restricts the creation of metadata fields when set to `true`. In other words, it indicates whether or not you are allowed to create new metadata definitions; for example, in the campaign manager or publication manager. If it is set to true, then only the defined fields will be available for assigning values.
  - `properties` object, required — Contains metadata definitions. There can be many properties within this object. Only the properties sent in the request will be updated. However, if you send a property, all its key-value pairs must be provided - otherwise, they will be overwritten to new values. You cannot change the `"type"` property. However, it is required, so you need to add it to the request.

## Response `200`

Returns the details about the updated metadata schema.

- ManagementProjectsMetadataSchemasUpdateResponseBody — Object representing a metadata schema.
  - `id` string, required — Unique identifier of the metadata schema.
  - `related_object` string, required — The resource type. You can define custom metadata schemas, which have a custom `"related_object"` resource type. The standard metadata schemas are: `"campaign"`, `"customer"`, `"earning_rule"`, `"loyalty_tier"`, `"order"`, `"order_item"`, `"product"`, `"promotion_tier"`, `"publication"`, `"redemption"`, `"reward"`, `"voucher"`.
  - `properties` object, required — Contains metadata definitions.
  - `allow_defined_only` boolean, nullable, required — Restricts the creation of metadata fields when set to `true`. It indicates whether or not you can create new metadata definitions, e.g. in the campaign or publication manager. If set to `true`, then only the defined fields are available for assigning values.
  - `created_at` string, date-time, required — Timestamp representing the date and time when the metadata schema was created. The value for this parameter is shown in the ISO 8601 format.
  - `updated_at` string, date-time, nullable, required — Timestamp representing the date and time when the metadata schema was updated. The value for this parameter is shown in the ISO 8601 format.
  - `object` string, required — The type of the object represented by the JSON. This object stores information about the metadata schema.

## Other responses

- `400` — Returns an error if the payload includes incorrect details.
- `401` — Returns an error if an invalid token was provided.
- `402` — Returns an error if the current plan does not include the Management API feature.
- `404` — Returns an error when a resource could not be found.

---

[API](https://skmtc.net/voucherifyio/apis/voucherify-api-async-actions.md) · [All operations](https://skmtc.net/voucherifyio/apis/voucherify-api-async-actions/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/voucherifyio/voucherify-api-async-actions/revisions/4982266e0494/schema)
