# themeCreate - admin-graphql - MUTATION Version: 2024-10 ## Description Creates a theme using an external URL or for files that were previously uploaded using the [stagedUploadsCreate mutation](https://shopify.dev/api/admin-graphql/latest/mutations/stageduploadscreate). These themes are added to the [Themes page](https://admin.shopify.com/themes) in Shopify admin. ### Access Scopes The user needs write_themes and an exemption from Shopify to modify themes. If you think that your app is eligible for an exemption and should have access to this API, then you can [submit an exception request](https://docs.google.com/forms/d/e/1FAIpQLSfZTB1vxFC5d1-GPdqYunWRGUoDcOheHQzfK2RoEFEHrknt5g/viewform). ## Arguments * [name](/docs/api/admin-graphql/2024-10/scalars/String): String - The name of the theme to be created. * [source](/docs/api/admin-graphql/2024-10/scalars/URL): URL! - An external URL or a [staged upload URL](https://shopify.dev/api/admin-graphql/latest/mutations/stageduploadscreate) of the theme to import. ## Returns * [theme](/docs/api/admin-graphql/2024-10/objects/OnlineStoreTheme): OnlineStoreTheme The theme that was created. * [userErrors](/docs/api/admin-graphql/2024-10/objects/ThemeCreateUserError): ThemeCreateUserError! The list of errors that occurred from executing the mutation. ## Examples ### Create a new theme from an url with a custom name 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 themeCreate($source: URL!, $name: String!) { themeCreate(source: $source, name: $name) { theme { name role } userErrors { field message } } }\",\n \"variables\": {\n \"source\": \"http://www.example.com/dawn.zip\",\n \"name\": \"Dawn\"\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation themeCreate($source: URL!, $name: String!) {\n themeCreate(source: $source, name: $name) {\n theme {\n name\n role\n }\n userErrors {\n field\n message\n }\n }\n }`,\n \"variables\": {\n \"source\": \"http://www.example.com/dawn.zip\",\n \"name\": \"Dawn\"\n },\n },\n});\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 themeCreate($source: URL!, $name: String!) {\n themeCreate(source: $source, name: $name) {\n theme {\n name\n role\n }\n userErrors {\n field\n message\n }\n }\n }\nQUERY\n\nvariables = {\n \"source\": \"http://www.example.com/dawn.zip\",\n \"name\": \"Dawn\"\n}\n\nresponse = client.query(query: query, variables: variables)\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation themeCreate($source: URL!, $name: String!) {\n themeCreate(source: $source, name: $name) {\n theme {\n name\n role\n }\n userErrors {\n field\n message\n }\n }\n }`,\n {\n variables: {\n \"source\": \"http://www.example.com/dawn.zip\",\n \"name\": \"Dawn\"\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation themeCreate($source: URL!, $name: String!) {\n themeCreate(source: $source, name: $name) {\n theme {\n name\n role\n }\n userErrors {\n field\n message\n }\n }\n}" #### Graphql Input { "source": "http://www.example.com/dawn.zip", "name": "Dawn" } #### Graphql Response { "data": { "themeCreate": { "theme": { "name": "Dawn", "role": "UNPUBLISHED" }, "userErrors": [] } } } ### Creates a theme 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 ThemeCreate($name: String, $source: URL!) { themeCreate(name: $name, source: $source) { theme { id } userErrors { code field message } } }\",\n \"variables\": {\n \"name\": \"New Theme\",\n \"source\": \"http://someurl.com/lemongrass.zip\"\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation ThemeCreate($name: String, $source: URL!) {\n themeCreate(name: $name, source: $source) {\n theme {\n id\n }\n userErrors {\n code\n field\n message\n }\n }\n }`,\n \"variables\": {\n \"name\": \"New Theme\",\n \"source\": \"http://someurl.com/lemongrass.zip\"\n },\n },\n});\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 ThemeCreate($name: String, $source: URL!) {\n themeCreate(name: $name, source: $source) {\n theme {\n id\n }\n userErrors {\n code\n field\n message\n }\n }\n }\nQUERY\n\nvariables = {\n \"name\": \"New Theme\",\n \"source\": \"http://someurl.com/lemongrass.zip\"\n}\n\nresponse = client.query(query: query, variables: variables)\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation ThemeCreate($name: String, $source: URL!) {\n themeCreate(name: $name, source: $source) {\n theme {\n id\n }\n userErrors {\n code\n field\n message\n }\n }\n }`,\n {\n variables: {\n \"name\": \"New Theme\",\n \"source\": \"http://someurl.com/lemongrass.zip\"\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation ThemeCreate($name: String, $source: URL!) {\n themeCreate(name: $name, source: $source) {\n theme {\n id\n }\n userErrors {\n code\n field\n message\n }\n }\n}" #### Graphql Input { "name": "New Theme", "source": "http://someurl.com/lemongrass.zip" } #### Graphql Response { "data": { "themeCreate": { "theme": { "id": "gid://shopify/OnlineStoreTheme/1049083724" }, "userErrors": [] } } }