marketing Activity Create Externalmutation
mutation
2025-01release candidate
Requires
write_marketing_events
access scope.
Creates a new external marketing activity.
Arguments
The input field for creating an external marketing activity.
Was this section helpful?
MarketingActivityCreateExternalPayload returns
The external marketing activity that was created.
The list of errors that occurred from executing the mutation.
Was this section helpful?
Examples
Hide code
DescriptionCopy
mutation marketingActivityCreateExternal($createInput: MarketingActivityCreateExternalInput!) { marketingActivityCreateExternal(input: $createInput) { marketingActivity { id } } }
curl -X POST \ https://your-development-store.myshopify.com/admin/api/2025-01/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Access-Token: {access_token}' \ -d '{ "query": "mutation marketingActivityCreateExternal($createInput: MarketingActivityCreateExternalInput!) { marketingActivityCreateExternal(input: $createInput) { marketingActivity { id } } }", "variables": { "createInput": { "remoteId": "fake_id", "title": "New Title", "remoteUrl": "https://example.com", "remotePreviewImageUrl": "https://example.com", "status": "ACTIVE", "utm": { "source": "email", "medium": "newsletter", "campaign": "external-campaign" }, "tactic": "NEWSLETTER", "marketingChannelType": "EMAIL" } } }'
const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql mutation marketingActivityCreateExternal($createInput: MarketingActivityCreateExternalInput!) { marketingActivityCreateExternal(input: $createInput) { marketingActivity { id } } }`, { variables: { "createInput": { "remoteId": "fake_id", "title": "New Title", "remoteUrl": "https://example.com", "remotePreviewImageUrl": "https://example.com", "status": "ACTIVE", "utm": { "source": "email", "medium": "newsletter", "campaign": "external-campaign" }, "tactic": "NEWSLETTER", "marketingChannelType": "EMAIL" } }, }, ); const data = await response.json();
session = ShopifyAPI::Auth::Session.new( shop: "your-development-store.myshopify.com", access_token: access_token ) client = ShopifyAPI::Clients::Graphql::Admin.new( session: session ) query = <<~QUERY mutation marketingActivityCreateExternal($createInput: MarketingActivityCreateExternalInput!) { marketingActivityCreateExternal(input: $createInput) { marketingActivity { id } } } QUERY variables = { "createInput": { "remoteId": "fake_id", "title": "New Title", "remoteUrl": "https://example.com", "remotePreviewImageUrl": "https://example.com", "status": "ACTIVE", "utm": { "source": "email", "medium": "newsletter", "campaign": "external-campaign" }, "tactic": "NEWSLETTER", "marketingChannelType": "EMAIL" } } response = client.query(query: query, variables: variables)
const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: { "query": `mutation marketingActivityCreateExternal($createInput: MarketingActivityCreateExternalInput!) { marketingActivityCreateExternal(input: $createInput) { marketingActivity { id } } }`, "variables": { "createInput": { "remoteId": "fake_id", "title": "New Title", "remoteUrl": "https://example.com", "remotePreviewImageUrl": "https://example.com", "status": "ACTIVE", "utm": { "source": "email", "medium": "newsletter", "campaign": "external-campaign" }, "tactic": "NEWSLETTER", "marketingChannelType": "EMAIL" } }, }, });
use Shopify\Clients\Graphql; $client = new Graphql("your-development-store.myshopify.com", $accessToken); $query = <<<QUERY mutation marketingActivityCreateExternal($createInput: MarketingActivityCreateExternalInput!) { marketingActivityCreateExternal(input: $createInput) { marketingActivity { id } } } QUERY; $variables = [ "createInput" => [ "remoteId" => "fake_id", "title" => "New Title", "remoteUrl" => "https://example.com", "remotePreviewImageUrl" => "https://example.com", "status" => "ACTIVE", "utm" => [ "source" => "email", "medium" => "newsletter", "campaign" => "external-campaign", ], "tactic" => "NEWSLETTER", "marketingChannelType" => "EMAIL", ], ]; $response = $client->query(["query" => $query, "variables" => $variables]);
Hide code
Input variables
Copy
{ "createInput": { "remoteId": "fake_id", "title": "New Title", "remoteUrl": "https://example.com", "remotePreviewImageUrl": "https://example.com", "status": "ACTIVE", "utm": { "source": "email", "medium": "newsletter", "campaign": "external-campaign" }, "tactic": "NEWSLETTER", "marketingChannelType": "EMAIL" } }
Hide code
Response
JSON
{ "marketingActivityCreateExternal": { "marketingActivity": { "id": "gid://shopify/MarketingActivity/1063897333" } } }