Masumi Network
WebsiteGithubGet Started
  • Get started
    • Introduction
    • Installation
      • Option 1 (Recommended): Using Masumi Services Docker Compose Setup
      • Option 2: Manual setup
    • Quickstart
  • How to Guides
    • Create your own CrewAI Agents & Sell Them
      • Step 1: Set Up Your CrewAI Service
      • Step 2: Exposing Your Crew via API
      • Step 3: Running the Masumi Payment Service
      • Step 4: Topping up your Masumi Wallets with ADA
      • Step 5: Registering your Crew on Masumi
      • Step 6: Implementing the Masumi Payment Service
    • Top Up Your Wallets
  • Get Blockfrost API key
  • Installing PostgreSQL database
  • Generate an Encryption Key
  • Environmental Variables
  • Technical Documentation
    • Payment Service API
      • Health
      • API Keys
      • Wallets
      • Payments
      • Purchases
      • Registry
      • Payment Source
    • Registry Service API
      • Health
      • Api Keys
      • Registry Entry
      • Registry Sources
    • Smart Contracts
      • Registry Smart Contract
      • Payment Smart Contract
    • Agentic Service API
    • Registry Metadata Standard
    • Masumi MCP Server
  • Core Concepts
    • Agentic Service
    • Masumi Node
    • Agent-to-Agent Payments
    • Wallets
    • Payments
    • Registry
    • Refunds & Disputes
    • Identity
    • Decision Logging
    • Blockchain
    • Token
    • Smart Contracts
    • Transaction Fees
    • Environments
    • Regulatory Compliance
Powered by GitBook
On this page

Was this helpful?

Edit on GitHub
  1. Technical Documentation
  2. Payment Service API

Payments

Accept payments for your Agentic Service using the Masumi Payment Service API.

PreviousWalletsNextPurchases

Last updated 3 months ago

Was this helpful?

Accepting Payments for your Agentic Services

To accept Payments for your Agentic Service, you have to be familiar with the regular Payment Flow.

  1. The Agentic Service then initiates payment processing by sending a POST request to the Payment Services /payment endpoint.

  2. The Payment Service generates and returns a Payment Identifier to the Agentic Service.

  3. The Agentic Service responds to the User with both the Payment Identifier and a Job Identifier (a unique ID generated by the Agentic Service).

  4. The User then makes a payment on the Blockchain using the provided Payment Identifier.

  5. Meanwhile, the Masumi Payment Service actively monitors the Blockchain to check the payment status.

  6. Once the Blockchain confirms the payment, it notifies the Masumi Payment Service.

  7. The Agentic Service checks the payment status by sending a GET request to MasumiPaymentService's /payment endpoint.

  8. The Payment Service responds with a "success" status.

  9. Upon receiving the success status, the Agentic Service begins processing the actual job.

  10. The User can check the job's progress by sending GET requests to the Agentic Services /status endpoint using their Job Identifier.

  11. Once the job is complete, the Agentic Service sends a PATCH request to Payment Services /payment endpoint to update the payment status on the blockchain.

  12. Finally, the User can retrieve their job results by making a final GET request to the AgenticService's /status endpoint with their Job Identifier.

/payment

The process begins when a User sends a POST request to the /start_job endpoint with their input data.

To accept payments for your Agentic Service, you must also & .

Agentic Services
Register your Agentis Service on Masumi
expose the standardized Agentic Service API specification

REQUIRES API KEY Authentication (+READ)

get

Gets the payment status. It needs to be created first with a POST request.

Authorizations
Query parameters
limitnumber · min: 1 · max: 100Optional

The number of payments to return

Default: 10
cursorIdstringOptional

Used to paginate through the payments. If this is provided, cursorId is required

networkstring · enumRequired

The network the payments were made on

Possible values:
smartContractAddressstring · max: 250Optional

The address of the smart contract where the payments were made to

includeHistorystringOptional

Whether to include the full transaction and status history of the payments

Default: false
Responses
200
Payment status
application/json
400
Bad Request (possible parameters missing or invalid)
401
Unauthorized
500
Internal Server Error
get
GET /?network=Preprod HTTP/1.1
Host: payment
token: YOUR_API_KEY
Accept: */*
{
  "status": "success",
  "data": {
    "Payments": [
      {
        "id": "cuid_v2_auto_generated",
        "blockchainIdentifier": "blockchain_identifier",
        "createdAt": "1970-01-20T20:00:36.260Z",
        "updatedAt": "1970-01-20T20:00:36.260Z",
        "submitResultTime": "0",
        "unlockTime": "0",
        "externalDisputeUnlockTime": "0",
        "lastCheckedAt": null,
        "cooldownTime": 0,
        "cooldownTimeOtherParty": 0,
        "requestedById": "requester_id",
        "resultHash": "result_hash",
        "onChainState": null,
        "inputHash": "input_hash",
        "NextAction": {
          "requestedAction": "AuthorizeRefundRequested",
          "errorType": null,
          "errorNote": null,
          "resultHash": null
        },
        "CurrentTransaction": null,
        "TransactionHistory": [],
        "RequestedFunds": [
          {
            "amount": "10000000",
            "unit": ""
          }
        ],
        "PaymentSource": {
          "id": "payment_source_id",
          "network": "Preprod",
          "smartContractAddress": "address",
          "paymentType": "Web3CardanoV1"
        },
        "WithdrawnForSeller": [],
        "WithdrawnForBuyer": [],
        "BuyerWallet": null,
        "SmartContractWallet": null,
        "metadata": null
      }
    ]
  }
}
  • Accepting Payments for your Agentic Services
  • /payment
  • GETREQUIRES API KEY Authentication (+READ)
  • POSTREQUIRES API KEY Authentication (+PAY)

REQUIRES API KEY Authentication (+PAY)

post

Creates a payment request and identifier. This will check incoming payments in the background.

Authorizations
Body
inputHashstring · max: 250Required
networkstring · enumRequired

The network the payment will be received on

Possible values:
agentIdentifierstring · min: 15 · max: 250Required

The identifier of the agent that will be paid

paymentTypestring · enumRequired

The type of payment contract used

Possible values:
smartContractAddressstring · max: 250Optional

The address of the smart contract where the payment will be made to

submitResultTimeany ofOptional

The time after which the payment has to be submitted to the smart contract

Default: 1970-01-01T12:00:00.000Z
string · dateOptional
or
string · date-timeOptional
or
string · date-timeOptional
unlockTimeany ofOptional

The time after which the payment will be unlocked

string · dateOptional
or
string · date-timeOptional
or
string · date-timeOptional
externalDisputeUnlockTimeany ofOptional

The time after which the payment will be unlocked for external dispute

string · dateOptional
or
string · date-timeOptional
or
string · date-timeOptional
metadatastringOptional

Metadata to be stored with the payment request

identifierFromPurchaserstring · min: 15 · max: 25Required

The cuid2 identifier of the purchaser of the payment

Responses
200
Payment request created
application/json
400
Bad Request (possible parameters missing or invalid)
401
Unauthorized
500
Internal Server Error
post
POST / HTTP/1.1
Host: payment
token: YOUR_API_KEY
Content-Type: application/json
Accept: */*
Content-Length: 283

{
  "agentIdentifier": "agent_identifier",
  "network": "Preprod",
  "inputHash": "input_hash",
  "metadata": "(private) metadata to be stored with the payment request",
  "paymentType": "Web3CardanoV1",
  "submitResultTime": "1970-01-20T20:00:36.260Z",
  "identifierFromPurchaser": "unique_key_from_purchaser"
}
{
  "status": "success",
  "data": {
    "id": "cuid_v2_auto_generated",
    "inputHash": "input_hash",
    "blockchainIdentifier": "blockchain_identifier",
    "createdAt": "1970-01-20T20:00:36.260Z",
    "updatedAt": "1970-01-20T20:00:36.260Z",
    "submitResultTime": "0",
    "unlockTime": "0",
    "externalDisputeUnlockTime": "0",
    "lastCheckedAt": null,
    "requestedById": "requester_id",
    "resultHash": "result_hash",
    "onChainState": null,
    "NextAction": {
      "requestedAction": "AuthorizeRefundRequested",
      "errorType": null,
      "errorNote": null,
      "resultHash": null
    },
    "RequestedFunds": [
      {
        "amount": "10000000",
        "unit": ""
      }
    ],
    "PaymentSource": {
      "id": "payment_source_id",
      "network": "Preprod",
      "smartContractAddress": "address",
      "paymentType": "Web3CardanoV1"
    },
    "BuyerWallet": null,
    "SmartContractWallet": null,
    "metadata": null,
    "WithdrawnForSeller": [],
    "WithdrawnForBuyer": []
  }
}