{
  "openapi": "3.1.1",
  "info": {
    "title": "Coop partner API",
    "description": "Tokens: POST /oauth/token with client_credentials and private_key_jwt (ES256) for the partner itself, or the urn:coop:grant-type:consent grant for a member's consent. Above the Sandbox tier every token is DPoP-bound (RFC 9449): send it as 'Authorization: DPoP <token>' with a fresh 'DPoP' proof per request. Send X-Coop-Tenant on token requests. Partner POSTs take an Idempotency-Key (required to create a circle). Errors are RFC 7807 problem details with errorCode and message.",
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "https://coop.aggregatesolution.net/"
    }
  ],
  "paths": {
    "/oauth/token": {
      "post": {
        "tags": [
          "Endpoints"
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/v1/partner/me": {
      "get": {
        "tags": [
          "Coop.Api"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PartnerMeView"
                }
              }
            }
          }
        }
      }
    },
    "/v1/partner/consents": {
      "post": {
        "tags": [
          "Coop.Api"
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StartConsentRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConsentStarted"
                }
              }
            }
          }
        }
      }
    },
    "/v1/partner/consents/{id}/confirm": {
      "post": {
        "tags": [
          "Coop.Api"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ConfirmConsentRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PartnerConsentView"
                }
              }
            }
          }
        }
      }
    },
    "/v1/partner/consents/{id}": {
      "get": {
        "tags": [
          "Coop.Api"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PartnerConsentView"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Coop.Api"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PartnerConsentView"
                }
              }
            }
          }
        }
      }
    },
    "/v1/partner/member/circles": {
      "get": {
        "tags": [
          "Coop.Api"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/PartnerCircleCard"
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Coop.Api"
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateCircleCommand"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CircleCreated"
                }
              }
            }
          }
        }
      }
    },
    "/v1/partner/member/circles/{id}": {
      "get": {
        "tags": [
          "Coop.Api"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PartnerCircleDetail"
                }
              }
            }
          }
        }
      }
    },
    "/v1/partner/member/accounts": {
      "get": {
        "tags": [
          "Coop.Api"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/PartnerAccountView"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/partner/member/circles/{id}/invites": {
      "post": {
        "tags": [
          "Coop.Api"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PartnerInviteRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "202": {
            "description": "Accepted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PartnerInviteAccepted"
                }
              }
            }
          }
        }
      }
    },
    "/v1/partner/member/circles/{id}/mandate-request": {
      "post": {
        "tags": [
          "Coop.Api"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PartnerRequestSent"
                }
              }
            }
          }
        }
      }
    },
    "/v1/partner/member/circles/{id}/contribution-request": {
      "post": {
        "tags": [
          "Coop.Api"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PartnerRequestSent"
                }
              }
            }
          }
        }
      }
    },
    "/v1/partner/webhook": {
      "get": {
        "tags": [
          "Coop.Api"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PartnerWebhookView"
                }
              }
            }
          }
        }
      },
      "put": {
        "tags": [
          "Coop.Api"
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SetWebhookRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PartnerWebhookView"
                }
              }
            }
          }
        }
      }
    },
    "/v1/partner/webhook/secret": {
      "post": {
        "tags": [
          "Coop.Api"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PartnerWebhookView"
                }
              }
            }
          }
        }
      }
    },
    "/v1/partner/webhook/deliveries": {
      "get": {
        "tags": [
          "Coop.Api"
        ],
        "parameters": [
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "pattern": "^-?(?:0|[1-9]\\d*)$",
              "type": [
                "integer",
                "string"
              ],
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookDeliveryPage"
                }
              }
            }
          }
        }
      }
    },
    "/v1/partner/webhook/deliveries/{id}/replay": {
      "post": {
        "tags": [
          "Coop.Api"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookDeliveryView"
                }
              }
            }
          }
        }
      }
    },
    "/v1/partner/referrals": {
      "post": {
        "tags": [
          "Coop.Api"
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PartnerReferralRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PartnerReferralView"
                }
              }
            }
          }
        }
      }
    },
    "/v1/partner/referrals/summary": {
      "get": {
        "tags": [
          "Coop.Api"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PartnerReferralSummary"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "CircleCreated": {
        "required": [
          "circleId",
          "name",
          "termsVersion"
        ],
        "type": "object",
        "properties": {
          "circleId": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "termsVersion": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "format": "int32"
          }
        }
      },
      "ConfirmConsentRequest": {
        "required": [
          "otp"
        ],
        "type": "object",
        "properties": {
          "otp": {
            "type": "string"
          }
        }
      },
      "ConsentStarted": {
        "required": [
          "consentId",
          "expiresInSeconds"
        ],
        "type": "object",
        "properties": {
          "consentId": {
            "type": "string",
            "format": "uuid"
          },
          "expiresInSeconds": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "format": "int32"
          }
        }
      },
      "CreateCircleCommand": {
        "required": [
          "name",
          "amountMinor",
          "frequency",
          "startDate",
          "rotation",
          "payoutPolicy",
          "maxMembers"
        ],
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "amountMinor": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "format": "int64"
          },
          "frequency": {
            "type": "string"
          },
          "startDate": {
            "type": "string",
            "format": "date"
          },
          "rotation": {
            "type": "string"
          },
          "payoutPolicy": {
            "type": [
              "null",
              "string"
            ]
          },
          "maxMembers": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "null",
              "integer",
              "string"
            ],
            "format": "int32"
          }
        }
      },
      "PartnerAccountView": {
        "required": [
          "nuban",
          "productName",
          "currency",
          "active"
        ],
        "type": "object",
        "properties": {
          "nuban": {
            "type": "string"
          },
          "productName": {
            "type": "string"
          },
          "currency": {
            "type": "string"
          },
          "active": {
            "type": "boolean"
          }
        }
      },
      "PartnerCircleCard": {
        "required": [
          "id",
          "name",
          "kind",
          "status",
          "frequency",
          "startDate",
          "members",
          "mySlot",
          "nextDueDate",
          "amountMinor",
          "outstandingMinor"
        ],
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "kind": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "frequency": {
            "type": "string"
          },
          "startDate": {
            "type": "string",
            "format": "date"
          },
          "members": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "format": "int32"
          },
          "mySlot": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "null",
              "integer",
              "string"
            ],
            "format": "int32"
          },
          "nextDueDate": {
            "type": [
              "null",
              "string"
            ],
            "format": "date"
          },
          "amountMinor": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "null",
              "integer",
              "string"
            ],
            "format": "int64"
          },
          "outstandingMinor": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "null",
              "integer",
              "string"
            ],
            "format": "int64"
          }
        }
      },
      "PartnerCircleDetail": {
        "required": [
          "id",
          "name",
          "kind",
          "status",
          "frequency",
          "payoutPolicy",
          "startDate",
          "amountMinor",
          "lateFeeMinor",
          "members",
          "rounds",
          "myContributions"
        ],
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "kind": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "frequency": {
            "type": "string"
          },
          "payoutPolicy": {
            "type": "string"
          },
          "startDate": {
            "type": "string",
            "format": "date"
          },
          "amountMinor": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "null",
              "integer",
              "string"
            ],
            "format": "int64"
          },
          "lateFeeMinor": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "null",
              "integer",
              "string"
            ],
            "format": "int64"
          },
          "members": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PartnerCircleMember"
            }
          },
          "rounds": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PartnerRound"
            }
          },
          "myContributions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PartnerContribution"
            }
          }
        }
      },
      "PartnerCircleMember": {
        "required": [
          "label",
          "isYou",
          "exited"
        ],
        "type": "object",
        "properties": {
          "label": {
            "type": "string"
          },
          "isYou": {
            "type": "boolean"
          },
          "exited": {
            "type": "boolean"
          }
        }
      },
      "PartnerConsentView": {
        "required": [
          "id",
          "status",
          "scopes",
          "purpose",
          "createdAt",
          "activatedAt",
          "expiresAt",
          "endedAt",
          "endedBy"
        ],
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "status": {
            "type": "string"
          },
          "scopes": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "purpose": {
            "type": "string"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "activatedAt": {
            "type": [
              "null",
              "string"
            ],
            "format": "date-time"
          },
          "expiresAt": {
            "type": [
              "null",
              "string"
            ],
            "format": "date-time"
          },
          "endedAt": {
            "type": [
              "null",
              "string"
            ],
            "format": "date-time"
          },
          "endedBy": {
            "type": [
              "null",
              "string"
            ]
          }
        }
      },
      "PartnerContribution": {
        "required": [
          "roundNo",
          "status",
          "outstandingMinor"
        ],
        "type": "object",
        "properties": {
          "roundNo": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "format": "int32"
          },
          "status": {
            "type": "string"
          },
          "outstandingMinor": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "null",
              "integer",
              "string"
            ],
            "format": "int64"
          }
        }
      },
      "PartnerInviteAccepted": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "default": "accepted"
          }
        }
      },
      "PartnerInviteRequest": {
        "required": [
          "phoneOrAccount"
        ],
        "type": "object",
        "properties": {
          "phoneOrAccount": {
            "type": "string"
          }
        }
      },
      "PartnerMeView": {
        "required": [
          "clientId",
          "name",
          "tier",
          "scopes",
          "consentId"
        ],
        "type": "object",
        "properties": {
          "clientId": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "tier": {
            "type": "string"
          },
          "scopes": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "consentId": {
            "type": [
              "null",
              "string"
            ],
            "format": "uuid"
          }
        }
      },
      "PartnerReferralRequest": {
        "required": [
          "phone",
          "personAgreed"
        ],
        "type": "object",
        "properties": {
          "phone": {
            "type": "string"
          },
          "personAgreed": {
            "type": "boolean"
          }
        }
      },
      "PartnerReferralSummary": {
        "required": [
          "referred",
          "open",
          "converted",
          "closed"
        ],
        "type": "object",
        "properties": {
          "referred": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "format": "int32"
          },
          "open": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "format": "int32"
          },
          "converted": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "format": "int32"
          },
          "closed": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "format": "int32"
          }
        }
      },
      "PartnerReferralView": {
        "required": [
          "referralId",
          "expiresAt"
        ],
        "type": "object",
        "properties": {
          "referralId": {
            "type": "string",
            "format": "uuid"
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "PartnerRequestSent": {
        "required": [
          "kind",
          "sentAt"
        ],
        "type": "object",
        "properties": {
          "kind": {
            "type": "string"
          },
          "sentAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "PartnerRound": {
        "required": [
          "no",
          "dueDate",
          "recipient",
          "status",
          "expectedMinor",
          "collectedMinor",
          "netMinor"
        ],
        "type": "object",
        "properties": {
          "no": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "format": "int32"
          },
          "dueDate": {
            "type": "string",
            "format": "date"
          },
          "recipient": {
            "type": [
              "null",
              "string"
            ]
          },
          "status": {
            "type": "string"
          },
          "expectedMinor": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "null",
              "integer",
              "string"
            ],
            "format": "int64"
          },
          "collectedMinor": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "null",
              "integer",
              "string"
            ],
            "format": "int64"
          },
          "netMinor": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "null",
              "integer",
              "string"
            ],
            "format": "int64"
          }
        }
      },
      "PartnerWebhookView": {
        "required": [
          "url",
          "secretVersion",
          "secret",
          "events"
        ],
        "type": "object",
        "properties": {
          "url": {
            "type": [
              "null",
              "string"
            ]
          },
          "secretVersion": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "format": "int32"
          },
          "secret": {
            "type": [
              "null",
              "string"
            ]
          },
          "events": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "SetWebhookRequest": {
        "required": [
          "url"
        ],
        "type": "object",
        "properties": {
          "url": {
            "type": [
              "null",
              "string"
            ]
          }
        }
      },
      "StartConsentRequest": {
        "required": [
          "nuban",
          "scopes",
          "purpose"
        ],
        "type": "object",
        "properties": {
          "nuban": {
            "type": "string"
          },
          "scopes": {
            "type": [
              "null",
              "array"
            ],
            "items": {
              "type": "string"
            }
          },
          "purpose": {
            "type": "string"
          }
        }
      },
      "WebhookDeliveryPage": {
        "required": [
          "items",
          "nextCursor"
        ],
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WebhookDeliveryView"
            }
          },
          "nextCursor": {
            "type": [
              "null",
              "string"
            ]
          }
        }
      },
      "WebhookDeliveryView": {
        "required": [
          "id",
          "type",
          "status",
          "attempts",
          "lastStatusCode",
          "lastError",
          "createdAt",
          "nextAttemptAt",
          "deliveredAt"
        ],
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "type": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "attempts": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "format": "int32"
          },
          "lastStatusCode": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "null",
              "integer",
              "string"
            ],
            "format": "int32"
          },
          "lastError": {
            "type": [
              "null",
              "string"
            ]
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "nextAttemptAt": {
            "type": [
              "null",
              "string"
            ],
            "format": "date-time"
          },
          "deliveredAt": {
            "type": [
              "null",
              "string"
            ],
            "format": "date-time"
          }
        }
      }
    }
  },
  "tags": [
    {
      "name": "Endpoints"
    },
    {
      "name": "Coop.Api"
    }
  ]
}