---
agentTools:
  projectIndex: https://gatoway.readme.io/llms.txt
---

# /api/v1/subscriptions/{id}

Patch Subscription

# OpenAPI definition

```json
{
  "openapi": "3.0.1",
  "info": {
    "title": "gatoway.app API",
    "description": "Payment API\n",
    "contact": {
      "name": "Support",
      "email": "support@gatoway.app"
    },
    "license": {
      "name": "Apache 2.0",
      "url": "http://www.apache.org/licenses/LICENSE-2.0.html"
    },
    "version": ""
  },
  "servers": [
    {
      "url": "https://engine-sandbox.gatoway.app",
      "description": "Sandbox"
    },
    {
      "url": "https://engine.gatoway.app",
      "description": "Production"
    }
  ],
  "tags": [
    {
      "name": "Subscription",
      "description": "Recurring Subscription API"
    }
  ],
  "paths": {
    "/api/v1/subscriptions/{id}": {
      "patch": {
        "tags": [
          "Subscription"
        ],
        "description": "Patch Subscription",
        "operationId": "patchSubscription",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Subscription Id",
            "required": true,
            "schema": {
              "pattern": "/[a-zA-Z0-9]{32}/",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "description": "Subscription patch request",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SubscriptionPatchRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Subscription Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SubscriptionResponse"
                }
              }
            }
          },
          "401": {
            "description": "Invalid credentials",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnauthorizedError"
                }
              }
            }
          },
          "404": {
            "description": "Subscription not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotFoundError"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuthentication": []
          }
        ],
        "x-codegen-request-body-name": "body"
      }
    }
  },
  "components": {
    "schemas": {
      "SubscriptionPatchRequest": {
        "type": "object",
        "properties": {
          "state": {
            "type": "string",
            "description": "New subscription state",
            "example": "CANCELLED",
            "enum": [
              "CANCELLED"
            ]
          }
        }
      },
      "SubscriptionResponse": {
        "type": "object",
        "properties": {
          "timestamp": {
            "type": "string",
            "format": "ISO 8601",
            "example": "2020-10-07T13:36:32.595Z"
          },
          "status": {
            "type": "integer",
            "description": "HTTP status code",
            "example": 200
          },
          "result": {
            "$ref": "#/components/schemas/Subscription"
          }
        }
      },
      "Subscription": {
        "type": "object",
        "properties": {
          "id": {
            "maxLength": 32,
            "type": "string",
            "description": "Subscription Id"
          },
          "customerReferenceId": {
            "maxLength": 128,
            "type": "string",
            "description": "Id of the customer from initial payment"
          },
          "description": {
            "maxLength": 512,
            "type": "string",
            "description": "Description for subsequent recurring payments",
            "example": "Subscription to service"
          },
          "amount": {
            "type": "number",
            "description": "The amount to be used for subsequent payments"
          },
          "currency": {
            "type": "string",
            "description": "Payment currency",
            "format": "ISO 4217 code for FIAT currencies or cryptocurrency symbol"
          },
          "createTime": {
            "type": "string",
            "format": "ISO 8601 (YYYY-MM-DD'T'HH24:MI:SS)",
            "description": "Date and time the subscription was created",
            "example": "2030-12-25T10:11:12"
          },
          "startTime": {
            "type": "string",
            "format": "ISO 8601 (YYYY-MM-DD'T'HH24:MI:SS)",
            "description": "Date and time of the 1st cycle",
            "example": "2030-12-25T10:11:12"
          },
          "frequency": {
            "type": "integer",
            "minimum": 1,
            "description": "The number of intervals after which a subscriber is billed. For example, if the frequencyUnit is DAY with an frequency of 2, the subscription is billed once every two days.",
            "example": 2
          },
          "frequencyUnit": {
            "type": "string",
            "description": "The interval at which the subscription is billed. Use 'MINUTE' for testing purposes only.",
            "example": "DAY",
            "enum": [
              "MINUTE",
              "DAY",
              "WEEK",
              "MONTH"
            ]
          },
          "requestedNumberOfCycles": {
            "type": "integer",
            "minimum": 1,
            "description": "Required number of subsequent recurring payments. Unlimited if value is not specified.",
            "example": 12
          },
          "state": {
            "type": "string",
            "description": "Subscription state",
            "example": "ACTIVE",
            "enum": [
              "ACTIVE",
              "CANCELLED",
              "COMPLETED"
            ]
          },
          "recurringToken": {
            "type": "string",
            "description": "Token that is used to continue the recurring chain"
          },
          "retryStrategy": {
            "$ref": "#/components/schemas/SubscriptionRetryStrategy"
          },
          "cycles": {
            "type": "array",
            "description": "List of payments automatically generated for this subscription",
            "items": {
              "$ref": "#/components/schemas/SubscriptionCycle"
            }
          }
        }
      },
      "SubscriptionCycle": {
        "type": "object",
        "properties": {
          "sequence": {
            "type": "integer",
            "description": "Sequence number of the cycle"
          },
          "type": {
            "type": "string",
            "description": "Cycle type",
            "example": "REGULAR",
            "enum": [
              "REGULAR",
              "RETRY"
            ]
          },
          "startTime": {
            "type": "string",
            "format": "ISO 8601 (YYYY-MM-DD'T'HH24:MI:SS)",
            "description": "Date and time when this cycle was supposed to be created according to the schedule",
            "example": "2030-12-25T10:11:12"
          },
          "paymentId": {
            "type": "string",
            "description": "Payment Id"
          },
          "paymentState": {
            "$ref": "#/components/schemas/PaymentState"
          },
          "amount": {
            "type": "number",
            "description": "Payment amount"
          }
        }
      },
      "SubscriptionRetryStrategy": {
        "required": [
          "frequency",
          "numberOfCycles"
        ],
        "type": "object",
        "properties": {
          "frequency": {
            "type": "integer",
            "minimum": 1,
            "description": "The number of intervals after which the system will retry the payment after an unsuccessful attempt",
            "example": 2
          },
          "frequencyUnit": {
            "type": "string",
            "description": "The interval at which the subscription is retried. Use 'MINUTE' for testing purposes only.",
            "example": "DAY",
            "enum": [
              "MINUTE",
              "DAY",
              "WEEK",
              "MONTH"
            ]
          },
          "numberOfCycles": {
            "type": "integer",
            "minimum": 1,
            "description": "Required number of retries",
            "example": 12
          },
          "amountAdjustments": {
            "type": "array",
            "description": "If specified, the nth element contains the percentage of the initial amount that will be charged for the nth retry",
            "items": {
              "type": "integer",
              "minimum": 1
            }
          }
        },
        "description": "Retry strategy for subscription. If not specified, the subscription is canceled after the first failed payment attempt."
      },
      "UnauthorizedError": {
        "required": [
          "status",
          "error",
          "message",
          "timestamp",
          "path"
        ],
        "type": "object",
        "properties": {
          "status": {
            "type": "integer",
            "example": 401
          },
          "error": {
            "type": "string",
            "example": "Unauthorized"
          },
          "message": {
            "type": "string",
            "example": "Invalid token"
          },
          "timestamp": {
            "type": "string",
            "format": "ISO 8601",
            "example": "2020-10-07T13:32:19.444Z"
          },
          "path": {
            "type": "string",
            "example": "/api/v1/payments"
          }
        },
        "example": {
          "status": 401,
          "error": "Unauthorized",
          "message": "Invalid token",
          "timestamp": "2020-10-07T13:32:19.444Z",
          "path": "/api/v1/resource-name"
        }
      },
      "NotFoundError": {
        "required": [
          "status",
          "error",
          "message",
          "timestamp",
          "path"
        ],
        "type": "object",
        "properties": {
          "status": {
            "type": "integer",
            "example": 404
          },
          "error": {
            "type": "string",
            "example": "Not Found"
          },
          "message": {
            "type": "string",
            "example": "404 NOT_FOUND"
          },
          "timestamp": {
            "type": "string",
            "format": "ISO 8601",
            "example": "2020-10-07T13:32:19.444Z"
          },
          "path": {
            "type": "string",
            "example": "/api/v1/payments"
          }
        },
        "example": {
          "status": 404,
          "error": "Not Found",
          "message": "404 NOT_FOUND",
          "timestamp": "2020-10-07T13:32:19.444Z",
          "path": "/api/v1/resource-name"
        }
      },
      "PaymentState": {
        "type": "string",
        "description": "Payment State",
        "example": "PENDING",
        "enum": [
          "CHECKOUT",
          "PENDING",
          "CANCELLED",
          "DECLINED",
          "COMPLETED"
        ]
      }
    },
    "securitySchemes": {
      "bearerAuthentication": {
        "type": "http",
        "description": "The client sends HTTP requests with the Authorization header that contains the word Bearer followed by a space and the Shop Api Key.",
        "scheme": "bearer"
      }
    }
  },
  "x-readme": {
    "explorer-enabled": true,
    "proxy-enabled": true
  },
  "_id": {
    "buffer": {
      "0": 102,
      "1": 178,
      "2": 46,
      "3": 9,
      "4": 62,
      "5": 149,
      "6": 149,
      "7": 0,
      "8": 24,
      "9": 12,
      "10": 84,
      "11": 125
    }
  }
}
```