- Customers
- Customer Address
- Retrieves a list of addresses for a customer
- Creates a new address for a customer
- Retrieves details for a single customer address
- Updates an existing customer address
- Removes an address from a customer’s address list
- Performs bulk operations for multiple customer addresses
- Sets the default address for a customer
- CustomerSavedSearch
- Customer
- Retrieves a list of customers
- Creates a customer
- Searches for customers that match a supplied query
- Retrieves a single customer
- Updates a customer
- Deletes a customer
- Creates an account activation URL for a customer
- Sends an account invite to a customer
- Retrieves a count of customers
- Retrieves all orders that belong to a customer
- Sales channels
- Checkout
- CollectionListing
- Retrieve collection listings that are published to your app
- Retrieve product_ids that are published to a collection_id
- Retrieve a specific collection listing that is published to your app
- Create a collection listing to publish a collection to your app
- Delete a collection listing to unpublish a collection from your app
- Product ResourceFeedback
- MobilePlatformApplication
- ProductListing
- Retrieve product listings that are published to your app
- Retrieve product_ids that are published to your app
- Retrieve a count of products that are published to your app
- Retrieve a specific product listing that is published to your app
- Create a product listing to publish a product to your app
- Delete a product listing to unpublish a product from your app
- ResourceFeedback
- Payment
- Products
- Collect
- Collection
- CustomCollection
- Product
- Product Image
- Product Variant
- SmartCollection
- Orders
- Access
- Billing
- Online store
- Asset
- Blog
- Article
- Retrieves a list of all articles from a blog
- Creates an article for a blog
- Retrieves a count of all articles from a blog
- Receive a single Article
- Updates an article
- Deletes an article
- Retrieves a list of all article authors
- Retrieves a list of all article tags
- Retrieves a list of all article tags from a specific blog
- Redirect
- Comment
- ScriptTag
- Page
- Theme
- Shipping and fulfillment
- CancellationRequest
- CarrierService
- AssignedFulfillmentOrder
- FulfillmentEvent
- Fulfillment
- Retrieves fulfillments associated with an order
- Retrieves fulfillments associated with a fulfillment order
- Retrieves a count of fulfillments associated with a specific order
- Receive a single Fulfillment
- Creates a fulfillment for one or many fulfillment orders
- Updates the tracking information for a fulfillment
- Cancels a fulfillment
- FulfillmentOrder
- Retrieves a list of fulfillment orders for a specific order
- Retrieves a specific fulfillment order
- Cancel a fulfillment order
- Marks a fulfillment order as incomplete
- Moves a fulfillment order to a new location
- Marks the fulfillment order as open
- Reschedules the fulfill_at time of a scheduled fulfillment order
- Applies a fulfillment hold on an open fulfillment order
- Sets deadline for fulfillment orders
- Releases the fulfillment hold on a fulfillment order
- LocationsForMove
- FulfillmentRequest
- FulfillmentService
- Shopify Payments
- Analytics
- Deprecated API calls
- Discounts
- DiscountCode
- Creates a discount codePOST
- Retrieves a list of discount codesGET
- Updates an existing discount codePUT
- Retrieves a single discount codeGET
- Deletes a discount codeDELETE
- Retrieves the location of a discount codeGET
- Retrieves a count of discount codes for a shopGET
- Creates a discount code creation jobPOST
- Retrieves a discount code creation jobGET
- Retrieves a list of discount codes for a discount code creation jobGET
- PriceRule
- Inventory
- Events
- MarketingEvent
- Metafield
- Plus
- Store properties
- TenderTransaction
Creates a discount code creation job
POST
/admin/api/{api_version}/price_rules/{price_rule_id}/batch.json
Creates a discount code creation job.
The batch endpoint can be used to asynchronously create up to 100 discount codes in a single request. It
enqueues and returns a discount_code_creation
object that can be monitored for completion.
You can enqueue a single creation job per a shop and you can't enqueue more until the job completes.
The price_rule_id
path parameter is the ID of the price rule that the discount code will belong to. This is required because
each discount code must belong to a price rule.
Response fields that are specific to the batch endpoint include:
status
: The state of the discount code creation job. Possible values are:queued
: The job is acknowledged, but not started.running
: The job is in process.completed
: The job has finished.
codes_count
: The number of discount codes to create.imported_count
: The number of discount codes created successfully.failed_count
: The number of discount codes that were not created successfully. Unsuccessful attempts will retry up to three times.logs
: A report that specifies when no discount codes were created because the provided data was invalid. Example responses:- "Price rule target selection can't be blank"
- "Price rule allocation method can't be blank"
请求参数
Path 参数
api_version
string
必需
price_rule_id
string
必需
示例代码
Shell
JavaScript
Java
Swift
Go
PHP
Python
HTTP
C
C#
Objective-C
Ruby
OCaml
Dart
R
请求示例请求示例
Shell
JavaScript
Java
Swift
curl --location --request POST 'https://demo.myshopify.com//admin/api//price_rules//batch.json'
返回响应
🟢201Creates a discount code creation job
application/json
Body
discount_code_creation
object
可选
id
number
可选
price_rule_id
number
可选
started_at
null
可选
completed_at
null
可选
created_at
string
可选
updated_at
string
可选
status
string
可选
codes_count
number
可选
imported_count
number
可选
failed_count
number
可选
logs
array
可选
示例
{
"discount_code_creation": {
"id": 989355119,
"price_rule_id": 507328175,
"started_at": null,
"completed_at": null,
"created_at": "2023-01-03T12:38:25-05:00",
"updated_at": "2023-01-03T12:38:25-05:00",
"status": "queued",
"codes_count": 3,
"imported_count": 0,
"failed_count": 0,
"logs": []
}
}
修改于 2023-01-29 12:00:31