Amazon SP API
    Amazon SP API
    • Overview
    • Authorization Workflow
    • Permissions
    • Sandbox
    • API Models
    • Available API Models
    • Request Apidog Access
    • OPENAPI SPECIFICATION
    • Research Docs
      • Amazon Seller Order Fulfillment Workflow
    • Amazon Warehousing and Distribution
      • getInboundShipment
        GET
      • listInboundShipments
        GET
      • listInventory
        GET
    • Authorization
      • Authorization
        POST
    • Catalog Items
      • searchCatalogItems
        GET
      • getCatalogItem
        GET
    • Catalog [Deprecated]
      • listCatalogItems
        GET
      • getCatalogItem
        GET
      • listCatalogCategories
        GET
    • Definitions
      • searchDefinitionsProductTypes
        GET
      • getDefinitionsProductType
        GET
    • Easy Ship
      • listHandoverSlots
        POST
      • getScheduledPackage
        GET
      • createScheduledPackage
        POST
      • updateScheduledPackages
        PATCH
      • createScheduledPackageBulk
        POST
    • FBAInbound
      • listInboundPlans
      • createInboundPlan
      • getInboundPlan
      • listInboundPlanBoxes
      • cancelInboundPlan
      • listInboundPlanItems
      • updateInboundPlanName
      • listPackingGroupBoxes
      • listPackingGroupItems
      • setPackingInformation
      • listPackingOptions
      • generatePackingOptions
      • confirmPackingOption
      • listInboundPlanPallets
      • listPlacementOptions
      • generatePlacementOptions
      • confirmPlacementOption
      • getShipment
      • listShipmentBoxes
      • listShipmentContentUpdatePreviews
      • generateShipmentContentUpdatePreviews
      • getShipmentContentUpdatePreview
      • confirmShipmentContentUpdatePreview
      • getDeliveryChallanDocument
      • listDeliveryWindowOptions
      • generateDeliveryWindowOptions
      • confirmDeliveryWindowOptions
      • listShipmentItems
      • updateShipmentName
      • listShipmentPallets
      • cancelSelfShipAppointment
      • getSelfShipAppointmentSlots
      • generateSelfShipAppointmentSlots
      • scheduleSelfShipAppointment
      • updateShipmentSourceAddress
      • updateShipmentTrackingDetails
      • listTransportationOptions
      • generateTransportationOptions
      • confirmTransportationOptions
      • listItemComplianceDetails
      • updateItemComplianceDetails
      • createMarketplaceItemLabels
      • listPrepDetails
      • setPrepDetails
      • getInboundOperationStatus
      • getItemEligibilityPreview
    • FBAInventory
      • getInventorySummaries
      • createInventoryItem
      • deleteInventoryItem
      • addInventory
    • FBAOutbound
      • getFulfillmentPreview
      • deliveryOffers
      • listAllFulfillmentOrders
      • createFulfillmentOrder
      • getPackageTrackingDetails
      • listReturnReasonCodes
      • createFulfillmentReturn
      • getFulfillmentOrder
      • updateFulfillmentOrder
      • cancelFulfillmentOrder
      • submitFulfillmentOrderStatusUpdate
      • getFeatures
      • getFeatureInventory
      • getFeatureSKU
    • Feeds
      • getFeeds
      • createFeed
      • cancelFeed
      • getFeed
      • createFeedDocument
      • getFeedDocument
    • Fees
      • getMyFeesEstimateForSKU
      • getMyFeesEstimateForASIN
      • getMyFeesEstimates
    • Finance
      • listTransactions
      • listFinancialEventGroups
      • listFinancialEventsByGroupId
      • listFinancialEventsByOrderId
      • listFinancialEvents
    • Invoices [Brazil]
      • getInvoicesAttributes
      • getInvoicesDocument
      • createInvoicesExport
      • getInvoicesExports
      • getInvoicesExport
      • getInvoices
      • getInvoice
    • Listings Items
      • getListingsRestrictions
      • deleteListingsItem
      • getListingsItem
      • patchListingsItem
      • putListingsItem
    • Merchant Fulfillment
      • getEligibleShipmentServices
      • getShipment
      • cancelShipment
      • createShipment
      • getAdditionalSellerInputs
    • Orders
      • getOrders
      • getOrder
      • getOrderBuyerInfo
      • getOrderAddress
      • getOrderItems
      • getOrderItemsBuyerInfo
      • updateShipmentStatus
      • getOrderRegulatedInfo
      • updateVerificationStatus
      • confirmShipment
    • ProductPricing
      • deprecated
        • getPricing
        • getCompetitivePricing
        • getListingOffers
        • getItemOffers
        • getItemOffersBatch
        • getListingOffersBatch
      • getFeaturedOfferExpectedPriceBatch
      • getCompetitiveSummary
    • Reports
      • getReports
      • createReport
      • cancelReport
      • getReport
      • getReportSchedules
      • createReportSchedule
      • cancelReportSchedule
      • getReportSchedule
      • getReportDocument
    • Sales
      • getOrderMetrics
    • Sellers
      • getMarketplaceParticipations
      • getAccount
    • Service
      • getServiceJobByServiceJobId
      • cancelServiceJobByServiceJobId
      • completeServiceJobByServiceJobId
      • getServiceJobs
      • addAppointmentForServiceJobByServiceJobId
      • rescheduleAppointmentForServiceJobByServiceJobId
      • assignAppointmentResources
      • setAppointmentFulfillmentData
      • getRangeSlotCapacity
      • getFixedSlotCapacity
      • updateSchedule
      • createReservation
      • updateReservation
      • cancelReservation
      • getAppointmmentSlotsByJobId
      • getAppointmentSlots
      • createServiceDocumentUploadDestination
    • ShipmentInvoice[Brazil]
      • getShipmentDetails
      • submitInvoice
      • getInvoiceStatus
    • Shipping
      • getRates
      • createShipment
      • directPurchaseShipment
      • getShipment
      • purchaseShipment
      • cancelShipment
      • oneClickShipment
      • purchaseLabels
      • getTracking
      • retrieveShippingLabel
      • getShipmentDocuments
      • purchaseShipment
      • cancelShipment
      • getRates
      • getAdditionalInputs
      • getAccount
      • getCarrierAccountFormInputs
      • getTrackingInformation
      • getCarrierAccounts
      • linkCarrierAccount
      • unlinkCarrierAccount
      • generateCollectionForm
      • getCollectionFormHistory
      • getUnmanifestedShipments
      • getCollectionForm
      • getAccessPoints
    • Supply Sources
      • getSupplySources
      • createSupplySource
      • getSupplySource
      • updateSupplySource
      • archiveSupplySource
      • updateSupplySourceStatus
    • Tokens
      • createRestrictedDataToken
    • Uploads
      • createUploadDestinationForResource
    • Notifications
      • getSubscription
      • createSubscription
      • getSubscriptionById
      • deleteSubscriptionById
      • getDestinations
      • createDestination
      • getDestination
      • deleteDestination

    Authorization Workflow

    This document explains the Website Authorization Workflow for connecting seller accounts to your application using Amazon's SP-API. It is a simplified and easy-to-follow guide, presented in clear, step-by-step instructions.

    What is Website Authorization Workflow?#

    The Website Authorization Workflow enables public applications to connect with Amazon seller accounts. Sellers authorize your app via Amazon's login page, and your app receives access tokens to interact with SP-API on their behalf.

    Prerequisites#

    Amazon Developer Account#

    Register as a developer at Amazon Developer Central.

    App Registration#

    Register your app in Amazon Seller Central:
    Obtain the Client ID, Client Secret, and App ID
    Define your OAuth Redirect URI

    Application Scope#

    Define the SP-API permissions (scopes) your app requires:
    Example: sellingpartnerapi::migration or sellingpartnerapi::notifications

    Step-by-Step Guide#

    Step 1: Build the Authorization URL#

    To initiate the workflow, direct the seller to Amazon's authorization page. Construct the URL as follows:
    Parameters:
    application_id: Your application's ID (e.g., amzn1.sellerapps.app.123456)
    state: A unique, random string to protect against CSRF attacks (e.g., secure_random_string)
    redirect_uri: Your app's callback URI (e.g., https://yourapp.com/oauth/callback)
    Example:
    https://sellercentral.amazon.com/apps/authorize/consent
    ?application_id=amzn1.sellerapps.app.123456
    &state=secure_random_string
    &redirect_uri=https://zamorins-sp-api.com/oauth/callback

    Step 2: Seller Logs In and Grants Permissions#

    1.
    The seller logs in to their Amazon account and reviews the permissions your app is requesting.
    2.
    Upon granting access, Amazon redirects the seller to your redirect_uri with the following query parameters:
    state: The same state string you sent (validate this)
    code: The authorization code you'll use to get tokens
    Example Redirect:

    Step 3: Exchange Authorization Code for Tokens#

    Make a POST request to Amazon's OAuth token endpoint to exchange the code for an access token and refresh token.
    Endpoint:
    https://api.amazon.com/auth/o2/token
    Request Parameters:
    {
      "grant_type": "authorization_code",
      "code": "<AUTHORIZATION_CODE>",
      "redirect_uri": "<YOUR_REDIRECT_URI>",
      "client_id": "<CLIENT_ID>",
      "client_secret": "<CLIENT_SECRET>"
    }
    Example Code (Python):
    Response Example:
    {
      "access_token": "Atza|IwEBL0B1...",
      "refresh_token": "Atzr|IwEBL0B1...",
      "token_type": "bearer",
      "expires_in": 3600
    }

    Step 4: Use Access Token for API Requests#

    Use the access_token to make API requests to SP-API endpoints on behalf of the seller. Include the token in the Authorization header:
    Example Request:

    Step 5: Refresh Tokens When Expired#

    Access tokens are short-lived (typically 1 hour). Use the refresh_token to request a new access_token.
    Request Parameters:
    {
      "grant_type": "refresh_token",
      "refresh_token": "<REFRESH_TOKEN>",
      "client_id": "<CLIENT_ID>",
      "client_secret": "<CLIENT_SECRET>"
    }
    Example Code:

    Best Practices#

    Store client_secret and refresh_token securely using tools like AWS Secrets Manager or encrypted databases
    Ensure the state parameter in the redirect matches your original string
    Implement retries for transient errors (e.g., 5xx responses)
    Schedule token refreshes before access tokens expire
    Gracefully handle scenarios where a seller revokes access

    Common Errors#

    Error CodeDescriptionSolution
    invalid_grantInvalid or expired authorization codeEnsure the code is valid and hasn't expired
    unauthorized_clientClient ID/Secret is invalidVerify your app credentials
    invalid_requestIncorrect request formatCheck all required parameters
    Previous
    Overview
    Next
    Permissions
    Built with