app Usage Record Createmutation
Enables an app to charge a store for features or services on a per-use basis.
The usage charge value is counted towards the capped
limit that was specified in the app
field when the app subscription was created.
If you create an app usage charge that causes the total usage charges in a billing interval to exceed the capped amount, then a Total price exceeds balance remaining
error is returned.
Arguments
The description of the app usage record.
Anchor to idempotencyKeyidempotencyKeyA unique key generated by the client to avoid duplicate charges. Maximum length of 255 characters.
The price of the app usage record.
The ID of the app subscription line item to create the usage record under. This app subscription line item must have a usage pricing plan.
AppUsageRecordCreatePayload returns
The newly created app usage record.
The list of errors that occurred from executing the mutation.
Code examples for MUTATION: appUsageRecordCreate
Query Reference for MUTATION: appUsageRecordCreate
"mutation appUsageRecordCreate($description: String!, $price: MoneyInput!, $subscriptionLineItemId: ID!) {\n appUsageRecordCreate(description: $description, price: $price, subscriptionLineItemId: $subscriptionLineItemId) {\n appUsageRecord {\n # AppUsageRecord fields\n }\n userErrors {\n field\n message\n }\n }\n}"
Input Reference for MUTATION: appUsageRecordCreate
"{\n \"description\": \"<your-description>\",\n \"idempotencyKey\": \"<your-idempotencyKey>\",\n \"price\": {\n \"amount\": \"29.99\",\n \"currencyCode\": \"AED\"\n },\n \"subscriptionLineItemId\": \"gid://shopify/<objectName>/10079785100\"\n}"
Schema Reference for MUTATION: appUsageRecordCreate
"input MoneyInput {\n amount: Decimal!\n currencyCode: CurrencyCode!\n}\n"
Display Examples for MUTATION: appUsageRecordCreate
[ { "example": { "type_name": "appusagerecordcreate", "title": "Create a new usage record", "query_string": "mutation appUsageRecordCreate($description: String!, $price: MoneyInput!, $subscriptionLineItemId: ID!) {\n appUsageRecordCreate(description: $description, price: $price, subscriptionLineItemId: $subscriptionLineItemId) {\n userErrors {\n field\n message\n }\n appUsageRecord {\n id\n }\n }\n}", "query_arguments": { "description": "$description", "price": "$price", "subscriptionLineItemId": "$subscriptionLineItemId" }, "variables": { "subscriptionLineItemId": "gid://shopify/AppSubscriptionLineItem/1029266946?v=1&index=1", "price": { "amount": 1, "currencyCode": "USD" }, "description": "Super Mega Plan 1000 emails" }, "response": { "data": { "appUsageRecordCreate": { "userErrors": [], "appUsageRecord": { "id": "gid://shopify/AppUsageRecord/1034618206" } } } }, "api_name": "admin", "minimum_api_version": "2023-10", "maximum_api_version": "unstable", "location": "/components/billing/test/unit/graph_api/admin/mutations/app_usage_record_create_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 appUsageRecordCreate($description: String!, $price: MoneyInput!, $subscriptionLineItemId: ID!) { appUsageRecordCreate(description: $description, price: $price, subscriptionLineItemId: $subscriptionLineItemId) { userErrors { field message } appUsageRecord { id } } }\",\n \"variables\": {\n \"subscriptionLineItemId\": \"gid://shopify/AppSubscriptionLineItem/1029266946?v=1&index=1\",\n \"price\": {\n \"amount\": 1.0,\n \"currencyCode\": \"USD\"\n },\n \"description\": \"Super Mega Plan 1000 emails\"\n }\n}'\n", "remix_example": "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation appUsageRecordCreate($description: String!, $price: MoneyInput!, $subscriptionLineItemId: ID!) {\n appUsageRecordCreate(description: $description, price: $price, subscriptionLineItemId: $subscriptionLineItemId) {\n userErrors {\n field\n message\n }\n appUsageRecord {\n id\n }\n }\n }`,\n {\n variables: {\n \"subscriptionLineItemId\": \"gid://shopify/AppSubscriptionLineItem/1029266946?v=1&index=1\",\n \"price\": {\n \"amount\": 1.0,\n \"currencyCode\": \"USD\"\n },\n \"description\": \"Super Mega Plan 1000 emails\"\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 appUsageRecordCreate($description: String!, $price: MoneyInput!, $subscriptionLineItemId: ID!) {\n appUsageRecordCreate(description: $description, price: $price, subscriptionLineItemId: $subscriptionLineItemId) {\n userErrors {\n field\n message\n }\n appUsageRecord {\n id\n }\n }\n }\nQUERY\n\nvariables = {\n \"subscriptionLineItemId\": \"gid://shopify/AppSubscriptionLineItem/1029266946?v=1&index=1\",\n \"price\": {\n \"amount\": 1.0,\n \"currencyCode\": \"USD\"\n },\n \"description\": \"Super Mega Plan 1000 emails\"\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 appUsageRecordCreate($description: String!, $price: MoneyInput!, $subscriptionLineItemId: ID!) {\n appUsageRecordCreate(description: $description, price: $price, subscriptionLineItemId: $subscriptionLineItemId) {\n userErrors {\n field\n message\n }\n appUsageRecord {\n id\n }\n }\n }`,\n \"variables\": {\n \"subscriptionLineItemId\": \"gid://shopify/AppSubscriptionLineItem/1029266946?v=1&index=1\",\n \"price\": {\n \"amount\": 1.0,\n \"currencyCode\": \"USD\"\n },\n \"description\": \"Super Mega Plan 1000 emails\"\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 appUsageRecordCreate($description: String!, $price: MoneyInput!, $subscriptionLineItemId: ID!) {\n appUsageRecordCreate(description: $description, price: $price, subscriptionLineItemId: $subscriptionLineItemId) {\n userErrors {\n field\n message\n }\n appUsageRecord {\n id\n }\n }\n }\nQUERY;\n\n$variables = [\n \"subscriptionLineItemId\" => \"gid://shopify/AppSubscriptionLineItem/1029266946?v=1&index=1\",\n \"price\" => [\n \"amount\" => 1.0,\n \"currencyCode\" => \"USD\",\n ],\n \"description\" => \"Super Mega Plan 1000 emails\",\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" }, "titleStringKey": "variables", "inputVariableEntries": [ { "arg": { "name": "subscriptionLineItemId", "description": "The ID of the app subscription line item to create the usage record under. This app subscription line item must have a usage pricing plan.", "type": { "kind": "SCALAR", "name": "ID", "list": false, "non_null": true }, "defaultValue": null, "typeSignature": "ID!", "isDeprecated": false, "deprecationReason": null, "kind": "ARGUMENT" }, "key": "subscriptionLineItemId", "argValue": " \"gid://shopify/AppSubscriptionLineItem/1029266946?v=1&index=1\"", "typeKind": "MUTATION" }, { "arg": { "name": "price", "description": "The price of the app usage record.", "type": { "kind": "INPUT_OBJECT", "name": "MoneyInput", "list": false, "non_null": true }, "defaultValue": null, "typeSignature": "MoneyInput!", "isDeprecated": false, "deprecationReason": null, "kind": "ARGUMENT" }, "key": "price", "argValue": " {\"amount\":1,\"currencyCode\":\"USD\"}", "typeKind": "MUTATION" }, { "arg": { "name": "description", "description": "The description of the app usage record.", "type": { "kind": "SCALAR", "name": "String", "list": false, "non_null": true }, "defaultValue": null, "typeSignature": "String!", "isDeprecated": false, "deprecationReason": null, "kind": "ARGUMENT" }, "key": "description", "argValue": " \"Super Mega Plan 1000 emails\"", "typeKind": "MUTATION" } ] }, { "example": { "type_name": "appusagerecordcreate", "title": "Creating a usage record above the capped amount returns an error", "description": "If the usage record would cause the capped amount specified on the usage pricing plan to be exceeded an error is returned.", "query_string": "mutation appUsageRecordCreate($description: String!, $price: MoneyInput!, $subscriptionLineItemId: ID!) {\n appUsageRecordCreate(description: $description, price: $price, subscriptionLineItemId: $subscriptionLineItemId) {\n userErrors {\n field\n message\n }\n appUsageRecord {\n id\n }\n }\n}", "query_arguments": { "description": "$description", "price": "$price", "subscriptionLineItemId": "$subscriptionLineItemId" }, "variables": { "subscriptionLineItemId": "gid://shopify/AppSubscriptionLineItem/1029266946?v=1&index=1", "price": { "amount": 100, "currencyCode": "USD" }, "description": "Super Mega Plan 1000 emails" }, "response": { "data": { "appUsageRecordCreate": { "userErrors": [ { "field": null, "message": "Failed to create usage charge" } ], "appUsageRecord": null } } }, "api_name": "admin", "minimum_api_version": "2023-10", "maximum_api_version": "unstable", "location": "/components/billing/test/unit/graph_api/admin/mutations/app_usage_record_create_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 appUsageRecordCreate($description: String!, $price: MoneyInput!, $subscriptionLineItemId: ID!) { appUsageRecordCreate(description: $description, price: $price, subscriptionLineItemId: $subscriptionLineItemId) { userErrors { field message } appUsageRecord { id } } }\",\n \"variables\": {\n \"subscriptionLineItemId\": \"gid://shopify/AppSubscriptionLineItem/1029266946?v=1&index=1\",\n \"price\": {\n \"amount\": 100.0,\n \"currencyCode\": \"USD\"\n },\n \"description\": \"Super Mega Plan 1000 emails\"\n }\n}'\n", "remix_example": "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation appUsageRecordCreate($description: String!, $price: MoneyInput!, $subscriptionLineItemId: ID!) {\n appUsageRecordCreate(description: $description, price: $price, subscriptionLineItemId: $subscriptionLineItemId) {\n userErrors {\n field\n message\n }\n appUsageRecord {\n id\n }\n }\n }`,\n {\n variables: {\n \"subscriptionLineItemId\": \"gid://shopify/AppSubscriptionLineItem/1029266946?v=1&index=1\",\n \"price\": {\n \"amount\": 100.0,\n \"currencyCode\": \"USD\"\n },\n \"description\": \"Super Mega Plan 1000 emails\"\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 appUsageRecordCreate($description: String!, $price: MoneyInput!, $subscriptionLineItemId: ID!) {\n appUsageRecordCreate(description: $description, price: $price, subscriptionLineItemId: $subscriptionLineItemId) {\n userErrors {\n field\n message\n }\n appUsageRecord {\n id\n }\n }\n }\nQUERY\n\nvariables = {\n \"subscriptionLineItemId\": \"gid://shopify/AppSubscriptionLineItem/1029266946?v=1&index=1\",\n \"price\": {\n \"amount\": 100.0,\n \"currencyCode\": \"USD\"\n },\n \"description\": \"Super Mega Plan 1000 emails\"\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 appUsageRecordCreate($description: String!, $price: MoneyInput!, $subscriptionLineItemId: ID!) {\n appUsageRecordCreate(description: $description, price: $price, subscriptionLineItemId: $subscriptionLineItemId) {\n userErrors {\n field\n message\n }\n appUsageRecord {\n id\n }\n }\n }`,\n \"variables\": {\n \"subscriptionLineItemId\": \"gid://shopify/AppSubscriptionLineItem/1029266946?v=1&index=1\",\n \"price\": {\n \"amount\": 100.0,\n \"currencyCode\": \"USD\"\n },\n \"description\": \"Super Mega Plan 1000 emails\"\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 appUsageRecordCreate($description: String!, $price: MoneyInput!, $subscriptionLineItemId: ID!) {\n appUsageRecordCreate(description: $description, price: $price, subscriptionLineItemId: $subscriptionLineItemId) {\n userErrors {\n field\n message\n }\n appUsageRecord {\n id\n }\n }\n }\nQUERY;\n\n$variables = [\n \"subscriptionLineItemId\" => \"gid://shopify/AppSubscriptionLineItem/1029266946?v=1&index=1\",\n \"price\" => [\n \"amount\" => 100.0,\n \"currencyCode\" => \"USD\",\n ],\n \"description\" => \"Super Mega Plan 1000 emails\",\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" }, "titleStringKey": "variables", "inputVariableEntries": [ { "arg": { "name": "subscriptionLineItemId", "description": "The ID of the app subscription line item to create the usage record under. This app subscription line item must have a usage pricing plan.", "type": { "kind": "SCALAR", "name": "ID", "list": false, "non_null": true }, "defaultValue": null, "typeSignature": "ID!", "isDeprecated": false, "deprecationReason": null, "kind": "ARGUMENT" }, "key": "subscriptionLineItemId", "argValue": " \"gid://shopify/AppSubscriptionLineItem/1029266946?v=1&index=1\"", "typeKind": "MUTATION" }, { "arg": { "name": "price", "description": "The price of the app usage record.", "type": { "kind": "INPUT_OBJECT", "name": "MoneyInput", "list": false, "non_null": true }, "defaultValue": null, "typeSignature": "MoneyInput!", "isDeprecated": false, "deprecationReason": null, "kind": "ARGUMENT" }, "key": "price", "argValue": " {\"amount\":100,\"currencyCode\":\"USD\"}", "typeKind": "MUTATION" }, { "arg": { "name": "description", "description": "The description of the app usage record.", "type": { "kind": "SCALAR", "name": "String", "list": false, "non_null": true }, "defaultValue": null, "typeSignature": "String!", "isDeprecated": false, "deprecationReason": null, "kind": "ARGUMENT" }, "key": "description", "argValue": " \"Super Mega Plan 1000 emails\"", "typeKind": "MUTATION" } ] }, { "example": { "type_name": "appusagerecordcreate", "title": "Creating usage record with idempotency key exceeding 255 characters results in an error.", "query_string": "mutation appUsageRecordCreate($description: String!, $price: MoneyInput!, $subscriptionLineItemId: ID!, $idempotencyKey: String) {\n appUsageRecordCreate(description: $description, price: $price, subscriptionLineItemId: $subscriptionLineItemId, idempotencyKey: $idempotencyKey) {\n userErrors {\n field\n message\n }\n appUsageRecord {\n id\n }\n }\n}", "query_arguments": { "description": "$description", "price": "$price", "subscriptionLineItemId": "$subscriptionLineItemId", "idempotencyKey": "$idempotencyKey" }, "variables": { "subscriptionLineItemId": "gid://shopify/AppSubscriptionLineItem/1029266946?v=1&index=1", "price": { "amount": 1, "currencyCode": "USD" }, "description": "Super Mega Plan 1000 emails", "idempotencyKey": "****************************************************************************************************************************************************************************************************************************************************************" }, "response": { "data": { "appUsageRecordCreate": { "userErrors": [ { "field": [ "idempotencyKey" ], "message": "Idempotency key exceeds the maximum length." } ], "appUsageRecord": null } } }, "api_name": "admin", "minimum_api_version": "2023-10", "maximum_api_version": "unstable", "location": "/components/billing/test/unit/graph_api/admin/mutations/app_usage_record_create_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 appUsageRecordCreate($description: String!, $price: MoneyInput!, $subscriptionLineItemId: ID!, $idempotencyKey: String) { appUsageRecordCreate(description: $description, price: $price, subscriptionLineItemId: $subscriptionLineItemId, idempotencyKey: $idempotencyKey) { userErrors { field message } appUsageRecord { id } } }\",\n \"variables\": {\n \"subscriptionLineItemId\": \"gid://shopify/AppSubscriptionLineItem/1029266946?v=1&index=1\",\n \"price\": {\n \"amount\": 1.0,\n \"currencyCode\": \"USD\"\n },\n \"description\": \"Super Mega Plan 1000 emails\",\n \"idempotencyKey\": \"****************************************************************************************************************************************************************************************************************************************************************\"\n }\n}'\n", "remix_example": "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation appUsageRecordCreate($description: String!, $price: MoneyInput!, $subscriptionLineItemId: ID!, $idempotencyKey: String) {\n appUsageRecordCreate(description: $description, price: $price, subscriptionLineItemId: $subscriptionLineItemId, idempotencyKey: $idempotencyKey) {\n userErrors {\n field\n message\n }\n appUsageRecord {\n id\n }\n }\n }`,\n {\n variables: {\n \"subscriptionLineItemId\": \"gid://shopify/AppSubscriptionLineItem/1029266946?v=1&index=1\",\n \"price\": {\n \"amount\": 1.0,\n \"currencyCode\": \"USD\"\n },\n \"description\": \"Super Mega Plan 1000 emails\",\n \"idempotencyKey\": \"****************************************************************************************************************************************************************************************************************************************************************\"\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 appUsageRecordCreate($description: String!, $price: MoneyInput!, $subscriptionLineItemId: ID!, $idempotencyKey: String) {\n appUsageRecordCreate(description: $description, price: $price, subscriptionLineItemId: $subscriptionLineItemId, idempotencyKey: $idempotencyKey) {\n userErrors {\n field\n message\n }\n appUsageRecord {\n id\n }\n }\n }\nQUERY\n\nvariables = {\n \"subscriptionLineItemId\": \"gid://shopify/AppSubscriptionLineItem/1029266946?v=1&index=1\",\n \"price\": {\n \"amount\": 1.0,\n \"currencyCode\": \"USD\"\n },\n \"description\": \"Super Mega Plan 1000 emails\",\n \"idempotencyKey\": \"****************************************************************************************************************************************************************************************************************************************************************\"\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 appUsageRecordCreate($description: String!, $price: MoneyInput!, $subscriptionLineItemId: ID!, $idempotencyKey: String) {\n appUsageRecordCreate(description: $description, price: $price, subscriptionLineItemId: $subscriptionLineItemId, idempotencyKey: $idempotencyKey) {\n userErrors {\n field\n message\n }\n appUsageRecord {\n id\n }\n }\n }`,\n \"variables\": {\n \"subscriptionLineItemId\": \"gid://shopify/AppSubscriptionLineItem/1029266946?v=1&index=1\",\n \"price\": {\n \"amount\": 1.0,\n \"currencyCode\": \"USD\"\n },\n \"description\": \"Super Mega Plan 1000 emails\",\n \"idempotencyKey\": \"****************************************************************************************************************************************************************************************************************************************************************\"\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 appUsageRecordCreate($description: String!, $price: MoneyInput!, $subscriptionLineItemId: ID!, $idempotencyKey: String) {\n appUsageRecordCreate(description: $description, price: $price, subscriptionLineItemId: $subscriptionLineItemId, idempotencyKey: $idempotencyKey) {\n userErrors {\n field\n message\n }\n appUsageRecord {\n id\n }\n }\n }\nQUERY;\n\n$variables = [\n \"subscriptionLineItemId\" => \"gid://shopify/AppSubscriptionLineItem/1029266946?v=1&index=1\",\n \"price\" => [\n \"amount\" => 1.0,\n \"currencyCode\" => \"USD\",\n ],\n \"description\" => \"Super Mega Plan 1000 emails\",\n \"idempotencyKey\" => \"****************************************************************************************************************************************************************************************************************************************************************\",\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" }, "titleStringKey": "variables", "inputVariableEntries": [ { "arg": { "name": "subscriptionLineItemId", "description": "The ID of the app subscription line item to create the usage record under. This app subscription line item must have a usage pricing plan.", "type": { "kind": "SCALAR", "name": "ID", "list": false, "non_null": true }, "defaultValue": null, "typeSignature": "ID!", "isDeprecated": false, "deprecationReason": null, "kind": "ARGUMENT" }, "key": "subscriptionLineItemId", "argValue": " \"gid://shopify/AppSubscriptionLineItem/1029266946?v=1&index=1\"", "typeKind": "MUTATION" }, { "arg": { "name": "price", "description": "The price of the app usage record.", "type": { "kind": "INPUT_OBJECT", "name": "MoneyInput", "list": false, "non_null": true }, "defaultValue": null, "typeSignature": "MoneyInput!", "isDeprecated": false, "deprecationReason": null, "kind": "ARGUMENT" }, "key": "price", "argValue": " {\"amount\":1,\"currencyCode\":\"USD\"}", "typeKind": "MUTATION" }, { "arg": { "name": "description", "description": "The description of the app usage record.", "type": { "kind": "SCALAR", "name": "String", "list": false, "non_null": true }, "defaultValue": null, "typeSignature": "String!", "isDeprecated": false, "deprecationReason": null, "kind": "ARGUMENT" }, "key": "description", "argValue": " \"Super Mega Plan 1000 emails\"", "typeKind": "MUTATION" }, { "arg": { "name": "idempotencyKey", "description": "A unique key generated by the client to avoid duplicate charges. Maximum length of 255 characters.", "type": { "kind": "SCALAR", "name": "String", "list": false, "non_null": false }, "defaultValue": null, "typeSignature": "String", "isDeprecated": false, "deprecationReason": null, "kind": "ARGUMENT" }, "key": "idempotencyKey", "argValue": " \"****************************************************************************************************************************************************************************************************************************************************************\"", "typeKind": "MUTATION" } ] }, { "example": { "type_name": "appusagerecordcreate", "title": "Creating usage record with idempotency key returns an error when another request for the same shop, app, idempotency key is in progress.", "query_string": "mutation appUsageRecordCreate($description: String!, $price: MoneyInput!, $subscriptionLineItemId: ID!, $idempotencyKey: String) {\n appUsageRecordCreate(description: $description, price: $price, subscriptionLineItemId: $subscriptionLineItemId, idempotencyKey: $idempotencyKey) {\n userErrors {\n field\n message\n }\n appUsageRecord {\n id\n }\n }\n}", "query_arguments": { "description": "$description", "price": "$price", "subscriptionLineItemId": "$subscriptionLineItemId", "idempotencyKey": "$idempotencyKey" }, "variables": { "subscriptionLineItemId": "gid://shopify/AppSubscriptionLineItem/1029266946?v=1&index=1", "price": { "amount": 1, "currencyCode": "USD" }, "description": "Super Mega Plan 1000 emails", "idempotencyKey": "Some idempotency key" }, "response": { "data": { "appUsageRecordCreate": { "userErrors": [ { "field": [ "idempotencyKey" ], "message": "Another request for the same idempotency key is being processed. Please try again." } ], "appUsageRecord": null } } }, "api_name": "admin", "minimum_api_version": "2023-10", "maximum_api_version": "unstable", "location": "/components/billing/test/unit/graph_api/admin/mutations/app_usage_record_create_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 appUsageRecordCreate($description: String!, $price: MoneyInput!, $subscriptionLineItemId: ID!, $idempotencyKey: String) { appUsageRecordCreate(description: $description, price: $price, subscriptionLineItemId: $subscriptionLineItemId, idempotencyKey: $idempotencyKey) { userErrors { field message } appUsageRecord { id } } }\",\n \"variables\": {\n \"subscriptionLineItemId\": \"gid://shopify/AppSubscriptionLineItem/1029266946?v=1&index=1\",\n \"price\": {\n \"amount\": 1.0,\n \"currencyCode\": \"USD\"\n },\n \"description\": \"Super Mega Plan 1000 emails\",\n \"idempotencyKey\": \"Some idempotency key\"\n }\n}'\n", "remix_example": "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation appUsageRecordCreate($description: String!, $price: MoneyInput!, $subscriptionLineItemId: ID!, $idempotencyKey: String) {\n appUsageRecordCreate(description: $description, price: $price, subscriptionLineItemId: $subscriptionLineItemId, idempotencyKey: $idempotencyKey) {\n userErrors {\n field\n message\n }\n appUsageRecord {\n id\n }\n }\n }`,\n {\n variables: {\n \"subscriptionLineItemId\": \"gid://shopify/AppSubscriptionLineItem/1029266946?v=1&index=1\",\n \"price\": {\n \"amount\": 1.0,\n \"currencyCode\": \"USD\"\n },\n \"description\": \"Super Mega Plan 1000 emails\",\n \"idempotencyKey\": \"Some idempotency key\"\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 appUsageRecordCreate($description: String!, $price: MoneyInput!, $subscriptionLineItemId: ID!, $idempotencyKey: String) {\n appUsageRecordCreate(description: $description, price: $price, subscriptionLineItemId: $subscriptionLineItemId, idempotencyKey: $idempotencyKey) {\n userErrors {\n field\n message\n }\n appUsageRecord {\n id\n }\n }\n }\nQUERY\n\nvariables = {\n \"subscriptionLineItemId\": \"gid://shopify/AppSubscriptionLineItem/1029266946?v=1&index=1\",\n \"price\": {\n \"amount\": 1.0,\n \"currencyCode\": \"USD\"\n },\n \"description\": \"Super Mega Plan 1000 emails\",\n \"idempotencyKey\": \"Some idempotency key\"\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 appUsageRecordCreate($description: String!, $price: MoneyInput!, $subscriptionLineItemId: ID!, $idempotencyKey: String) {\n appUsageRecordCreate(description: $description, price: $price, subscriptionLineItemId: $subscriptionLineItemId, idempotencyKey: $idempotencyKey) {\n userErrors {\n field\n message\n }\n appUsageRecord {\n id\n }\n }\n }`,\n \"variables\": {\n \"subscriptionLineItemId\": \"gid://shopify/AppSubscriptionLineItem/1029266946?v=1&index=1\",\n \"price\": {\n \"amount\": 1.0,\n \"currencyCode\": \"USD\"\n },\n \"description\": \"Super Mega Plan 1000 emails\",\n \"idempotencyKey\": \"Some idempotency key\"\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 appUsageRecordCreate($description: String!, $price: MoneyInput!, $subscriptionLineItemId: ID!, $idempotencyKey: String) {\n appUsageRecordCreate(description: $description, price: $price, subscriptionLineItemId: $subscriptionLineItemId, idempotencyKey: $idempotencyKey) {\n userErrors {\n field\n message\n }\n appUsageRecord {\n id\n }\n }\n }\nQUERY;\n\n$variables = [\n \"subscriptionLineItemId\" => \"gid://shopify/AppSubscriptionLineItem/1029266946?v=1&index=1\",\n \"price\" => [\n \"amount\" => 1.0,\n \"currencyCode\" => \"USD\",\n ],\n \"description\" => \"Super Mega Plan 1000 emails\",\n \"idempotencyKey\" => \"Some idempotency key\",\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" }, "titleStringKey": "variables", "inputVariableEntries": [ { "arg": { "name": "subscriptionLineItemId", "description": "The ID of the app subscription line item to create the usage record under. This app subscription line item must have a usage pricing plan.", "type": { "kind": "SCALAR", "name": "ID", "list": false, "non_null": true }, "defaultValue": null, "typeSignature": "ID!", "isDeprecated": false, "deprecationReason": null, "kind": "ARGUMENT" }, "key": "subscriptionLineItemId", "argValue": " \"gid://shopify/AppSubscriptionLineItem/1029266946?v=1&index=1\"", "typeKind": "MUTATION" }, { "arg": { "name": "price", "description": "The price of the app usage record.", "type": { "kind": "INPUT_OBJECT", "name": "MoneyInput", "list": false, "non_null": true }, "defaultValue": null, "typeSignature": "MoneyInput!", "isDeprecated": false, "deprecationReason": null, "kind": "ARGUMENT" }, "key": "price", "argValue": " {\"amount\":1,\"currencyCode\":\"USD\"}", "typeKind": "MUTATION" }, { "arg": { "name": "description", "description": "The description of the app usage record.", "type": { "kind": "SCALAR", "name": "String", "list": false, "non_null": true }, "defaultValue": null, "typeSignature": "String!", "isDeprecated": false, "deprecationReason": null, "kind": "ARGUMENT" }, "key": "description", "argValue": " \"Super Mega Plan 1000 emails\"", "typeKind": "MUTATION" }, { "arg": { "name": "idempotencyKey", "description": "A unique key generated by the client to avoid duplicate charges. Maximum length of 255 characters.", "type": { "kind": "SCALAR", "name": "String", "list": false, "non_null": false }, "defaultValue": null, "typeSignature": "String", "isDeprecated": false, "deprecationReason": null, "kind": "ARGUMENT" }, "key": "idempotencyKey", "argValue": " \"Some idempotency key\"", "typeKind": "MUTATION" } ] } ]