Adobe Commerce only. Learn more.

createGiftRegistry mutation

The createGiftRegistry mutation creates a gift registry for the logged in customer.

This mutation requires a valid customer authentication token.

The id input attribute is optional. If a value is not specified, Magento will create one. If you specify a value, then you can create a gift registry and make multiple updates in a single call.

When assigning a shipping address, you must specify only one of address_data or address_id.

Only the gift registry owner can view the following output attributes:

  • created_at
  • privacy_settings
  • shipping_address
  • status

Syntax

1
2
3
4
5
6
7
mutation {
  createGiftRegistry(
    giftRegistry: CreateGiftRegistryInput!
  ) {
    CreateGiftRegistryOutput
  }
}

Example usage

The following example creates a gift registry.

Request:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
mutation {
  createGiftRegistry(
    giftRegistry: {
      giftRegistryTypeUid: "Mw=="
      event_name: "Bill and Julie's wedding"
      message: "Help us celebrate Bill and Julie's wedding, which will be held on May 1, 2021"
      privacy_settings: PRIVATE
      status: ACTIVE
      shipping_address: {
        address_id: 1
      }
      registrants: [
        {
          firstname: "Julie"
          lastname: "Rao"
          email: "julierao@example.com"
          dynamic_attributes: [{
            code: "role"
            value: "Bride" }]
        }
        {
          firstname: "Bill"
          lastname: "Preston"
          email: "bpreston@example.com"
          dynamic_attributes: [{
            code: "role"
            value: "Groom" }]
        }
      ]
      dynamic_attributes: [
        {
          code: "number_of_guests"
          value: "101"
        }
        {
          code: "event_date"
          value: "2021-05-01"
        }
        {
          code: "event_country"
          value: "US"
        }
        {
          code: "event_location"
          value: "Ann Arbor, MI"
        }
      ]
    }
  ) {
    gift_registry {
      uid
      event_name
      message
      owner_name
      privacy_settings
      status
      registrants {
        uid
        firstname
        lastname
        email
        dynamic_attributes {
          code
          label
          value
        }
      }
      type {
        uid
        label
      }
      items {
        uid
        product {
          uid
          sku
          name
        }
        quantity
        quantity_fulfilled
      }
      shipping_address {
        firstname
        lastname
        street
        region {
          region
        }
        postcode
        country_code
      }
    }
  }
}

Response:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
{
  "data": {
    "createGiftRegistry": {
      "gift_registry": {
        "uid": "iSJHFdAtF8YBM5ALgNyNIgQmnbOW9t69",
        "event_name": "Bill and Julie's wedding",
        "message": "Help us celebrate Bill and Julie's wedding, which will be held on May 1, 2021",
        "owner_name": "Veronica Costello",
        "privacy_settings": "PRIVATE",
        "status": "ACTIVE",
        "registrants": [
          {
            "uid": "OQ==",
            "firstname": "Julie",
            "lastname": "Rao",
            "email": "julierao@example.com",
            "dynamic_attributes": [
              {
                "code": "role",
                "label": "Role",
                "value": "Bride"
              }
            ]
          },
          {
            "uid": "MTA=",
            "firstname": "Bill",
            "lastname": "Preston",
            "email": "bpreston@example.com",
            "dynamic_attributes": [
              {
                "code": "role",
                "label": "Role",
                "value": "Groom"
              }
            ]
          }
        ],
        "type": {
          "uid": "Mw==",
          "label": "Wedding"
        },
        "items": [],
        "shipping_address": {
          "firstname": "Veronica",
          "lastname": "Costello",
          "street": [
            "6146 Honey Bluff Parkway"
          ],
          "region": {
            "region": "Michigan"
          },
          "postcode": "49628-7978",
          "country_code": "US"
        }
      }
    }
  }
}

Input attributes

The CreateGiftRegistryInput input object defines the gift registry.

Attribute Data Type Description
dynamic_attributes [GiftRegistryDynamicAttributeInput] An array of attributes that define elements of the gift registry. Each attribute is specified as a code-value pair
event_name String! The name of the event
giftRegistryTypeUid ID! The ID of the selected event type
giftRegistryUid ID An optional gift registry ID. It can be generated on the client and then be used to send multiple gift-registry related mutations in a single request
message String! A message describing the event
privacy_settings GiftRegistryPrivacySettings! Indicates whether the registry is PRIVATE or PUBLIC
registrants [AddGiftRegistryRegistrantInput!]! The list of people who receive notifications about the registry
shipping_address GiftRegistryShippingAddressInput The address for shipping the gift registry. Specify either the address_data object or the address_id attribute. Validation fails if both are provided
status GiftRegistryStatus! An enum that states whether the gift registry is ACTIVE or INACTIVE. Only the registry owner can access this attribute

AddGiftRegistryRegistrantInput attributes

The AddGiftRegistryRegistrantInput object contains the following attributes:

Attribute Data Type Description
dynamic_attributes [GiftRegistryDynamicAttributeInput] An array of attributes that define elements of the gift registry. Each attribute is specified as a code-value pair
email String! The email address of the registrant
firstname String! The first name of the registrant
lastname String! The last name of the registrant

GiftRegistryDynamicAttributeInput attributes

The GiftRegistryDynamicAttributeInput object contains the following attributes:

Attribute Data Type Description
code ID! A unique key for an additional attribute of the event
value String! A corresponding value for the code

GiftRegistryShippingAddressInput attributes

The GiftRegistryShippingAddressInput object contains the following attributes:

Attribute Data Type Description
address_data CustomerAddressInput The complete details of the shipping address
address_id ID The ID of predefined customer address

CustomerAddressInput attributes

The CustomerAddressInput object can contain the following attributes:

Attribute Data Type Description
city String The city or town
company String The customer’s company
country_code String The customer’s country
country_id String Deprecated. Use country_code instead. The customer’s country
custom_attributes CustomerAddressAttributeInput Deprecated. Not applicable for GraphQL
default_billing Boolean Indicates whether the address is the default billing address
default_shipping Boolean Indicates whether the address is the default shipping address
fax String The fax number
firstname String The first name of the person associated with the shipping/billing address
lastname String The family name of the person associated with the shipping/billing address
middlename String The middle name of the person associated with the shipping/billing address
postcode String The customer’s ZIP or postal code
prefix String An honorific, such as Dr., Mr., or Mrs.
region CustomerAddressRegionInput An object that defines the customer’s state or province
street [String] An array of strings that define the street number and name
suffix String A value such as Sr., Jr., or III
telephone String The telephone number
vat_id String The customer’s Tax/VAT number (for corporate customers)

CustomerAddressAttributeInput attributes

The CustomerAddressAttributeInput data type has been deprecated because the contents are not applicable for GraphQL. It can contain the following attributes:

Attribute Data Type Description
attribute_code String Attribute code
value String Attribute value

CustomerAddressRegionInput attributes

The customerAddressRegionInput object can contain the following attributes:

Attribute Data Type Description
region String The state or province name
region_code String The address region code
region_id Int Deprecated. Use region instead. Uniquely identifies the region

Output attributes

The CreateGiftRegistryOutput output object contains the following attribute:

Attribute Data Type Description
gift_registry GiftRegistry Contains the created gift registry

GiftRegistry attributes

The GiftRegistry object returns the following attributes:

Attribute Data Type Description
created_at String! The date on which the gift registry was created. Only the registry owner can access this attribute
dynamic_attributes [GiftRegistryDynamicAttribute] An array of attributes that define elements of the gift registry. Each attribute is specified as a code-value pair
event_name String! The name the customer assigned to the event
items [GiftRegistryItemInterface] An array of products added to the gift registry
message String! The message text the customer entered to describe the event
owner_name String! The customer who created the gift registry
privacy_settings GiftRegistryPrivacySettings! An enum that states whether the gift registry is PRIVATE or PUBLIC. Only the registry owner can access this attribute
registrants [GiftRegistryRegistrant] Contains details about each registrant for the event
shipping_address CustomerAddress Contains the customer’s shipping address. Only the registry owner can access this attribute
status GiftRegistryStatus! An enum that states whether the gift registry is ACTIVE or INACTIVE. Only the registry owner can access this attribute
type [GiftRegistryType] Contains details about the type of gift registry
uid ID! The unique ID assigned to the gift registry

GiftRegistryDynamicAttribute attributes

The GiftRegistryDynamicAttribute object implements GiftRegistryDynamicAttributeInterface. It also defines the following attribute.

Attribute Data Type Description
group GiftRegistryDynamicAttributeGroup! An enum that categorizes the dynamic attribute set. The possible values are EVENT_INFORMATION, PRIVACY_SETTINGS, REGISTRANT, GENERAL_INFORMATION, DETAILED_INFORMATION, and SHIPPING_ADDRESS.

GiftRegistryDynamicAttributeInterface attributes

The GiftRegistryDynamicAttribute and GiftRegistryRegistrantDynamicAttribute data types implement the GiftRegistryDynamicAttributeInterface.

This interface contains the following attributes:

Attribute Data type Description
code ID! The internal ID of the dynamic attribute
label String! The display name of the dynamic attribute
value String! A corresponding value for the code

GiftRegistryDynamicAttributeMetadataInterface

The GiftRegistryDynamicAttributeMetadata data type implements the GiftRegistryDynamicAttributeMetadataInterface.

This interface contains the following attributes:

Attribute Data Type Description
attribute_group String! Indicates which group of the dynamic attribute a member of
code ID! The internal ID of the dynamic attribute
input_type String! The input type of the dynamic attribute
is_required Boolean! Indicates whether the dynamic attribute is required
label String! The display name of the dynamic attribute
sort_order Int The order in which to display the dynamic attribute

GiftRegistryItemInterface attributes

This GiftRegistryItemInterface contains the following attributes:

Attribute Data Type Description
created_at String! The date the product was added to the gift registry
note String A brief message about the gift registry item
product ProductInterface The details about the product
quantity Float! The requested quantity of the product
quantity_fulfilled Float! The fulfilled quantity of the product
uid ID! The unique ID assigned to the gift registry item

GiftRegistryRegistrant attributes

The GiftRegistryRegistrant object contains the following attributes:

Attribute Data type Description
dynamic_attributes [GiftRegistryRegistrantDynamicAttribute] An array of attributes that define elements of the gift registry. Each attribute is specified as a code-value pair
email String! The email address of the registrant. Only the registry owner can access this attribute
firstname String! The first name of the registrant
lastname String! The last name of the registrant
uid ID! The unique ID assigned to the registrant

GiftRegistryRegistrantDynamicAttribute attributes

The GiftRegistryRegistrantDynamicAttribute data type implements the GiftRegistryDynamicAttributeInterface. It does not introduce any additional attributes.

GiftRegistryType attributes

The GiftRegistryType object contains the following attributes:

Attribute Data type Description
dynamic_attributes_metadata [GiftRegistryDynamicAttributeMetadataInterface] An array of attributes that define elements of the gift registry. Each attribute is specified as a code-value pair
label String! The display name of the gift registry type
uid ID! The unique ID assigned to the gift registry type