Update a schema

PUT /groups/{groupId}/apps/{appId}/schemas/{schemaId}

Replace an existing schema with a new one.

Path parameters

application/json

Body Required

  • metadata object

    Metadata that describes which linked collection the schema applies to.

    Hide metadata attributes Show metadata attributes object
    • data_source string

      The data source name.

    • database string

      The database name.

    • collection string

      The collection name.

  • schema object

    A valid schema for the collection.

    Hide schema attributes Show schema attributes object
    • bsonType string

      The BSON type of the field.

      Values are object, array, string, number, int, long, double, decimal, date, timestamp, bool, null, regex, objectId, binary, uuid, function, javascript, symbol, minKey, or maxKey.

    • title string

      A human-readable title for the schema.

    • required array[string]

      For object schemas, an array of field names that are required in instances of the object.

    • properties object

      An object where each field name is a property in the schema. The corresponding value is a schema definition for that field.

      Hide properties attribute Show properties attribute object
      • * object

        A valid schema for the collection.

  • relationships object

    Relationships to foreign collections. Each field name is a property in the schema. The corresponding value is a relationship definition for that field.

    Hide relationships attribute Show relationships attribute object
    • * object Additional properties

      A relationship definition.

      Hide * attributes Show * attributes object
      • ref string

        A reference string for the foreign collection.

      • foreign_key string

        The name of the field in the foreign collection that the relationship points to.

      • is_list boolean

        If true:

        • the relationship may point to many foreign documents.
        • the local field must be defined as an array in the collection schema.

Responses

  • 204

    No Content

PUT /groups/{groupId}/apps/{appId}/schemas/{schemaId}
curl \
 --request PUT 'https://services.cloud.mongodb.com/api/admin/v3.0/groups/{groupId}/apps/{appId}/schemas/{schemaId}' \
 --header "Authorization: Bearer $ACCESS_TOKEN" \
 --header "Content-Type: application/json" \
 --data '{"metadata":{"data_source":"string","database":"string","collection":"string"},"schema":{"bsonType":"object","title":"string","required":["string"],"properties":{"*":{}}},"relationships":{"additionalProperty1":{"ref":"string","foreign_key":"string","is_list":true},"additionalProperty2":{"ref":"string","foreign_key":"string","is_list":true}}}'
Request examples
{
  "metadata": {
    "data_source": "string",
    "database": "string",
    "collection": "string"
  },
  "schema": {
    "bsonType": "object",
    "title": "string",
    "required": [
      "string"
    ],
    "properties": {
      "*": {}
    }
  },
  "relationships": {
    "additionalProperty1": {
      "ref": "string",
      "foreign_key": "string",
      "is_list": true
    },
    "additionalProperty2": {
      "ref": "string",
      "foreign_key": "string",
      "is_list": true
    }
  }
}