marketing Activity Upsert Externalmutation
mutation
2024-10latest
Requires write
access scope.
Creates a new external marketing activity or updates an existing one. When optional fields are absent or null, associated information will be removed from an existing marketing activity.
Arguments
The input field for creating or updating an external marketing activity.
Was this section helpful?
MarketingActivityUpsertExternalPayload returns
The external marketing activity that was created or updated.
The list of errors that occurred from executing the mutation.
Was this section helpful?
Code examples for MUTATION: marketingActivityUpsertExternal
Query Reference for MUTATION: marketingActivityUpsertExternal
"mutation marketingActivityUpsertExternal($input: MarketingActivityUpsertExternalInput!) {\n marketingActivityUpsertExternal(input: $input) {\n marketingActivity {\n # MarketingActivity fields\n }\n userErrors {\n field\n message\n }\n }\n}"
Input Reference for MUTATION: marketingActivityUpsertExternal
"{\n \"input\": {\n \"adSpend\": {\n \"amount\": \"29.99\",\n \"currencyCode\": \"AED\"\n },\n \"budget\": {\n \"budgetType\": \"DAILY\",\n \"total\": {\n \"amount\": \"29.99\",\n \"currencyCode\": \"AED\"\n }\n },\n \"channelHandle\": \"<your-channelHandle>\",\n \"end\": \"2019-09-07T15:50:00Z\",\n \"hierarchyLevel\": \"AD\",\n \"marketingChannelType\": \"DISPLAY\",\n \"parentRemoteId\": \"<your-parentRemoteId>\",\n \"referringDomain\": \"<your-referringDomain>\",\n \"remoteId\": \"<your-remoteId>\",\n \"remotePreviewImageUrl\": \"https://example.myshopify.com\",\n \"remoteUrl\": \"https://example.myshopify.com\",\n \"scheduledEnd\": \"2019-09-07T15:50:00Z\",\n \"scheduledStart\": \"2019-09-07T15:50:00Z\",\n \"start\": \"2019-09-07T15:50:00Z\",\n \"status\": \"ACTIVE\",\n \"tactic\": \"ABANDONED_CART\",\n \"title\": \"<your-title>\",\n \"urlParameterValue\": \"<your-urlParameterValue>\",\n \"utm\": {\n \"campaign\": \"<your-campaign>\",\n \"medium\": \"<your-medium>\",\n \"source\": \"<your-source>\"\n }\n }\n}"
Schema Reference for MUTATION: marketingActivityUpsertExternal
"input MarketingActivityUpsertExternalInput {\n adSpend: MoneyInput\n budget: MarketingActivityBudgetInput\n channelHandle: String\n end: DateTime\n hierarchyLevel: MarketingActivityHierarchyLevel\n marketingChannelType: MarketingChannel!\n parentRemoteId: String\n referringDomain: String\n remoteId: String!\n remotePreviewImageUrl: URL\n remoteUrl: URL!\n scheduledEnd: DateTime\n scheduledStart: DateTime\n start: DateTime\n status: MarketingActivityExternalStatus!\n tactic: MarketingTactic!\n title: String!\n urlParameterValue: String\n utm: UTMInput\n}\n\ninput MoneyInput {\n amount: Decimal!\n currencyCode: CurrencyCode!\n}\n\ninput MarketingActivityBudgetInput {\n budgetType: MarketingBudgetBudgetType\n total: MoneyInput\n}\n\ninput UTMInput {\n campaign: String!\n medium: String!\n source: String!\n}\n"
Display Examples for MUTATION: marketingActivityUpsertExternal
[ { "example": { "type_name": "marketingactivityupsertexternal", "title": "Upsert (create or update) an external marketing activity", "query_string": "mutation marketingActivityUpsertExternal($input: MarketingActivityUpsertExternalInput!) {\n marketingActivityUpsertExternal(input: $input) {\n marketingActivity {\n id\n }\n }\n}", "variables": { "input": { "remoteId": "A unique identifier", "title": "New Title", "remoteUrl": "https://example.com", "status": "ACTIVE", "utm": { "source": "email", "medium": "newsletter", "campaign": "external-campaign" }, "tactic": "NEWSLETTER", "marketingChannelType": "EMAIL" } }, "response": { "data": { "marketingActivityUpsertExternal": { "marketingActivity": { "id": "gid://shopify/MarketingActivity/1063897336" } } } }, "api_name": "admin", "minimum_api_version": "2024-01", "maximum_api_version": "unstable", "location": "/components/merchant_marketing/test/unit/graph_api/admin/mutations/marketing_activity_upsert_external_test.rb", "curl_example": "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation marketingActivityUpsertExternal($input: MarketingActivityUpsertExternalInput!) { marketingActivityUpsertExternal(input: $input) { marketingActivity { id } } }\",\n \"variables\": {\n \"input\": {\n \"remoteId\": \"A unique identifier\",\n \"title\": \"New Title\",\n \"remoteUrl\": \"https://example.com\",\n \"status\": \"ACTIVE\",\n \"utm\": {\n \"source\": \"email\",\n \"medium\": \"newsletter\",\n \"campaign\": \"external-campaign\"\n },\n \"tactic\": \"NEWSLETTER\",\n \"marketingChannelType\": \"EMAIL\"\n }\n }\n}'\n", "remix_example": "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation marketingActivityUpsertExternal($input: MarketingActivityUpsertExternalInput!) {\n marketingActivityUpsertExternal(input: $input) {\n marketingActivity {\n id\n }\n }\n }`,\n {\n variables: {\n \"input\": {\n \"remoteId\": \"A unique identifier\",\n \"title\": \"New Title\",\n \"remoteUrl\": \"https://example.com\",\n \"status\": \"ACTIVE\",\n \"utm\": {\n \"source\": \"email\",\n \"medium\": \"newsletter\",\n \"campaign\": \"external-campaign\"\n },\n \"tactic\": \"NEWSLETTER\",\n \"marketingChannelType\": \"EMAIL\"\n }\n },\n },\n);\n\nconst data = await response.json();\n", "ruby_example": "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n mutation marketingActivityUpsertExternal($input: MarketingActivityUpsertExternalInput!) {\n marketingActivityUpsertExternal(input: $input) {\n marketingActivity {\n id\n }\n }\n }\nQUERY\n\nvariables = {\n \"input\": {\n \"remoteId\": \"A unique identifier\",\n \"title\": \"New Title\",\n \"remoteUrl\": \"https://example.com\",\n \"status\": \"ACTIVE\",\n \"utm\": {\n \"source\": \"email\",\n \"medium\": \"newsletter\",\n \"campaign\": \"external-campaign\"\n },\n \"tactic\": \"NEWSLETTER\",\n \"marketingChannelType\": \"EMAIL\"\n }\n}\n\nresponse = client.query(query: query, variables: variables)\n", "node_example": "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation marketingActivityUpsertExternal($input: MarketingActivityUpsertExternalInput!) {\n marketingActivityUpsertExternal(input: $input) {\n marketingActivity {\n id\n }\n }\n }`,\n \"variables\": {\n \"input\": {\n \"remoteId\": \"A unique identifier\",\n \"title\": \"New Title\",\n \"remoteUrl\": \"https://example.com\",\n \"status\": \"ACTIVE\",\n \"utm\": {\n \"source\": \"email\",\n \"medium\": \"newsletter\",\n \"campaign\": \"external-campaign\"\n },\n \"tactic\": \"NEWSLETTER\",\n \"marketingChannelType\": \"EMAIL\"\n }\n },\n },\n});\n", "php_example": "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n mutation marketingActivityUpsertExternal($input: MarketingActivityUpsertExternalInput!) {\n marketingActivityUpsertExternal(input: $input) {\n marketingActivity {\n id\n }\n }\n }\nQUERY;\n\n$variables = [\n \"input\" => [\n \"remoteId\" => \"A unique identifier\",\n \"title\" => \"New Title\",\n \"remoteUrl\" => \"https://example.com\",\n \"status\" => \"ACTIVE\",\n \"utm\" => [\n \"source\" => \"email\",\n \"medium\" => \"newsletter\",\n \"campaign\" => \"external-campaign\",\n ],\n \"tactic\" => \"NEWSLETTER\",\n \"marketingChannelType\" => \"EMAIL\",\n ],\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" }, "titleStringKey": "variables", "inputVariableEntries": [ { "arg": { "name": "input", "description": "The input field for creating or updating an external marketing activity.", "type": { "kind": "INPUT_OBJECT", "name": "MarketingActivityUpsertExternalInput", "list": false, "non_null": true }, "defaultValue": null, "typeSignature": "MarketingActivityUpsertExternalInput!", "isDeprecated": false, "deprecationReason": null, "kind": "ARGUMENT" }, "key": "input", "argValue": " {\"remoteId\":\"A unique identifier\",\"title\":\"New Title\",\"remoteUrl\":\"https://example.com\",\"status\":\"ACTIVE\",\"utm\":{\"source\":\"email\",\"medium\":\"newsletter\",\"campaign\":\"external-campaign\"},\"tactic\":\"NEWSLETTER\",\"marketingChannelType\":\"EMAIL\"}", "typeKind": "MUTATION" } ] } ]