{
  "openapi": "3.1.0",
  "info": {
    "title": "Marketing",
    "description": "Campaigns, campaign categories, campaign costs, campaign cost summary, email channel cost",
    "version": "1.0"
  },
  "servers": [
    {
      "url": "https://api.servicetitan.io/marketing/v2",
      "description": "Production"
    },
    {
      "url": "https://api-integration.servicetitan.io/marketing/v2",
      "description": "Integration"
    }
  ],
  "paths": {
    "/tenant/{tenant}/categories": {
      "get": {
        "tags": [
          "CampaignCategories"
        ],
        "summary": "Gets a paginated list of campaign categories",
        "operationId": "CampaignCategories_GetList",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "Tenant ID",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "page",
            "in": "query",
            "description": "The logical number of page to return, starting from 1",
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "pageSize",
            "in": "query",
            "description": "How many records to return (50 by default)",
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "includeTotal",
            "in": "query",
            "description": "Whether total count should be returned",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "createdBefore",
            "in": "query",
            "description": "Return items created before certain date/time (in UTC)",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "createdOnOrAfter",
            "in": "query",
            "description": "Return items created on or after certain date/time (in UTC)",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "modifiedBefore",
            "in": "query",
            "description": "Return items modified before certain date/time (in UTC)",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "modifiedOnOrAfter",
            "in": "query",
            "description": "Return items modified on or after certain date/time (in UTC)",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "sort",
            "in": "query",
            "description": "Applies sorting by the specified field:\\\n\"?sort=+FieldName\" for ascending order,\\\n\"?sort=-FieldName\" for descending order.\\\n\\\nAvailable fields are: Id, CreatedOn, Name",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The request has succeeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaginatedResponse_Of_Marketing.V2.CampaignCategoryResponse"
                },
                "example": {
                  "page": 0,
                  "pageSize": 0,
                  "hasMore": true,
                  "totalCount": 0,
                  "data": [
                    {
                      "id": 0,
                      "name": "string",
                      "active": true,
                      "type": "Regular",
                      "createdOn": "string",
                      "modifiedOn": "string"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "The request cannot be processed, check validation errors or request format",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                },
                "example": {
                  "type": "string",
                  "title": "string",
                  "status": 0,
                  "traceId": "string",
                  "errors": {},
                  "data": {}
                }
              }
            }
          }
        },
        "security": [
          {
            "apiKeyHeader": [],
            "oauth": [
              "tn.mrk.categories:r"
            ]
          }
        ]
      },
      "post": {
        "tags": [
          "CampaignCategories"
        ],
        "summary": "Creates new campaign category",
        "operationId": "CampaignCategories_Create",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "Tenant ID",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Marketing.V2.CampaignCategoryCreateRequest"
              },
              "example": {
                "name": "string"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The request has succeeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ModificationResponse"
                },
                "example": {
                  "id": 0
                }
              }
            }
          },
          "400": {
            "description": "The request cannot be processed, check validation errors or request format",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                },
                "example": {
                  "type": "string",
                  "title": "string",
                  "status": 0,
                  "traceId": "string",
                  "errors": {},
                  "data": {}
                }
              }
            }
          }
        },
        "security": [
          {
            "apiKeyHeader": [],
            "oauth": [
              "tn.mrk.categories:w"
            ]
          }
        ]
      }
    },
    "/tenant/{tenant}/categories/{id}": {
      "get": {
        "tags": [
          "CampaignCategories"
        ],
        "summary": "Gets campaign category specified by ID",
        "operationId": "CampaignCategories_Get",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "tenant",
            "in": "path",
            "description": "Tenant ID",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The request has succeeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Marketing.V2.CampaignCategoryResponse"
                },
                "example": {
                  "id": 0,
                  "name": "string",
                  "active": true,
                  "type": "Regular",
                  "createdOn": "string",
                  "modifiedOn": "string"
                }
              }
            }
          },
          "400": {
            "description": "The request cannot be processed, check validation errors or request format",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                },
                "example": {
                  "type": "string",
                  "title": "string",
                  "status": 0,
                  "traceId": "string",
                  "errors": {},
                  "data": {}
                }
              }
            }
          }
        },
        "security": [
          {
            "apiKeyHeader": [],
            "oauth": [
              "tn.mrk.categories:r"
            ]
          }
        ]
      },
      "patch": {
        "tags": [
          "CampaignCategories"
        ],
        "summary": "Updates specified campaign category in \"patch\" mode",
        "operationId": "CampaignCategories_Update",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "tenant",
            "in": "path",
            "description": "Tenant ID",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Marketing.V2.CampaignCategoryUpdateRequest"
              },
              "example": {
                "name": "string",
                "active": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The request has succeeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ModificationResponse"
                },
                "example": {
                  "id": 0
                }
              }
            }
          },
          "400": {
            "description": "The request cannot be processed, check validation errors or request format",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                },
                "example": {
                  "type": "string",
                  "title": "string",
                  "status": 0,
                  "traceId": "string",
                  "errors": {},
                  "data": {}
                }
              }
            }
          }
        },
        "security": [
          {
            "apiKeyHeader": [],
            "oauth": [
              "tn.mrk.categories:w"
            ]
          }
        ]
      }
    },
    "/tenant/{tenant}/costs": {
      "get": {
        "tags": [
          "CampaignCosts"
        ],
        "summary": "Gets a paginated list of campaign costs",
        "operationId": "CampaignCosts_GetList",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "Tenant ID",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "page",
            "in": "query",
            "description": "The logical number of page to return, starting from 1",
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "pageSize",
            "in": "query",
            "description": "How many records to return (50 by default)",
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "includeTotal",
            "in": "query",
            "description": "Whether total count should be returned",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "year",
            "in": "query",
            "description": "Year",
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "month",
            "in": "query",
            "description": "Month",
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "campaignId",
            "in": "query",
            "description": "Campaign ID",
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "sort",
            "in": "query",
            "description": "Applies sorting by the specified field:\\\n\"?sort=+FieldName\" for ascending order,\\\n\"?sort=-FieldName\" for descending order.\\\n\\\nAvailable fields are: Id, Date (Year + Month)",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The request has succeeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaginatedResponse_Of_Marketing.V2.CampaignCostResponse"
                },
                "example": {
                  "page": 0,
                  "pageSize": 0,
                  "hasMore": true,
                  "totalCount": 0,
                  "data": [
                    {
                      "id": 0,
                      "year": 0,
                      "month": 0,
                      "dailyCost": 0,
                      "campaignId": 0
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "The request cannot be processed, check validation errors or request format",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                },
                "example": {
                  "type": "string",
                  "title": "string",
                  "status": 0,
                  "traceId": "string",
                  "errors": {},
                  "data": {}
                }
              }
            }
          }
        },
        "security": [
          {
            "apiKeyHeader": [],
            "oauth": [
              "tn.mrk.costs:r"
            ]
          }
        ]
      },
      "post": {
        "tags": [
          "CampaignCosts"
        ],
        "summary": "Creates new campaign cost",
        "operationId": "CampaignCosts_Create",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "Tenant ID",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Marketing.V2.CreateCampaignCostRequest"
              },
              "example": {
                "campaignId": 0,
                "year": 0,
                "month": 0,
                "dailyCost": 0
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The request has succeeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Marketing.V2.CampaignCostResponse"
                },
                "example": {
                  "id": 0,
                  "year": 0,
                  "month": 0,
                  "dailyCost": 0,
                  "campaignId": 0
                }
              }
            }
          },
          "400": {
            "description": "The request cannot be processed, check validation errors or request format",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                },
                "example": {
                  "type": "string",
                  "title": "string",
                  "status": 0,
                  "traceId": "string",
                  "errors": {},
                  "data": {}
                }
              }
            }
          }
        },
        "security": [
          {
            "apiKeyHeader": [],
            "oauth": [
              "tn.mrk.costs:w"
            ]
          }
        ]
      }
    },
    "/tenant/{tenant}/costs/{id}": {
      "get": {
        "tags": [
          "CampaignCosts"
        ],
        "summary": "Gets campaign cost specified by ID",
        "operationId": "CampaignCosts_Get",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "tenant",
            "in": "path",
            "description": "Tenant ID",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The request has succeeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Marketing.V2.CampaignCostResponse"
                },
                "example": {
                  "id": 0,
                  "year": 0,
                  "month": 0,
                  "dailyCost": 0,
                  "campaignId": 0
                }
              }
            }
          },
          "400": {
            "description": "The request cannot be processed, check validation errors or request format",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                },
                "example": {
                  "type": "string",
                  "title": "string",
                  "status": 0,
                  "traceId": "string",
                  "errors": {},
                  "data": {}
                }
              }
            }
          }
        },
        "security": [
          {
            "apiKeyHeader": [],
            "oauth": [
              "tn.mrk.costs:r"
            ]
          }
        ]
      },
      "patch": {
        "tags": [
          "CampaignCosts"
        ],
        "summary": "Updates specified campaign cost in \"patch\" mode",
        "operationId": "CampaignCosts_Update",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "tenant",
            "in": "path",
            "description": "Tenant ID",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Marketing.V2.UpdateCampaignCostRequest"
              },
              "example": {
                "dailyCost": 0
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The request has succeeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ModificationResponse"
                },
                "example": {
                  "id": 0
                }
              }
            }
          },
          "400": {
            "description": "The request cannot be processed, check validation errors or request format",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                },
                "example": {
                  "type": "string",
                  "title": "string",
                  "status": 0,
                  "traceId": "string",
                  "errors": {},
                  "data": {}
                }
              }
            }
          }
        },
        "security": [
          {
            "apiKeyHeader": [],
            "oauth": [
              "tn.mrk.costs:w"
            ]
          }
        ]
      }
    },
    "/tenant/{tenant}/campaign-cost-summary": {
      "get": {
        "tags": [
          "CampaignCostSummary"
        ],
        "operationId": "CampaignCostSummary_Get",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "Tenant ID",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The request has succeeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Marketing.V2.CampaignCostsSummaryResponse"
                },
                "example": {
                  "items": [
                    {
                      "campaignId": 0,
                      "campaignName": "string",
                      "totalCost": 0
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "The request cannot be processed, check validation errors or request format",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                },
                "example": {
                  "type": "string",
                  "title": "string",
                  "status": 0,
                  "traceId": "string",
                  "errors": {},
                  "data": {}
                }
              }
            }
          }
        },
        "security": [
          {
            "apiKeyHeader": [],
            "oauth": [
              "tn.mrk.campaigncostsummary:r"
            ]
          }
        ]
      }
    },
    "/tenant/{tenant}/campaigns": {
      "get": {
        "tags": [
          "Campaigns"
        ],
        "summary": "Gets a paginated list of campaigns",
        "operationId": "Campaigns_GetList",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "Tenant ID",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "page",
            "in": "query",
            "description": "The logical number of page to return, starting from 1",
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "pageSize",
            "in": "query",
            "description": "How many records to return (50 by default)",
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "includeTotal",
            "in": "query",
            "description": "Whether total count should be returned",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "modifiedBefore",
            "in": "query",
            "description": "Return items modified before certain date/time (in UTC)",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "modifiedOnOrAfter",
            "in": "query",
            "description": "Return items modified on or after certain date/time (in UTC)",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "active",
            "in": "query",
            "description": "What kind of items should be returned (only active items will be returned by default)\\\nValues: [True, Any, False]",
            "schema": {
              "type": "string",
              "oneOf": [
                {
                  "$ref": "#/components/schemas/ActiveRequestArg"
                }
              ]
            }
          },
          {
            "name": "ids",
            "in": "query",
            "description": "Perform lookup by multiple IDs (maximum 50)",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "name",
            "in": "query",
            "description": "Filters records by name (case-insensitive \"contains\" operation)",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "createdBefore",
            "in": "query",
            "description": "Return items created before certain date/time (in UTC)",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "createdOnOrAfter",
            "in": "query",
            "description": "Return items created on or after certain date/time (in UTC)",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "campaignPhoneNumber",
            "in": "query",
            "description": "Filters campaigns by phone number (as string).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sort",
            "in": "query",
            "description": "Applies sorting by the specified field:\\\n\"?sort=+FieldName\" for ascending order,\\\n\"?sort=-FieldName\" for descending order.\\\n\\\nAvailable fields are: Id, Name, CreatedOn, ModifiedOn",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The request has succeeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaginatedResponse_Of_Marketing.V2.CampaignResponse"
                },
                "example": {
                  "page": 0,
                  "pageSize": 0,
                  "hasMore": true,
                  "totalCount": 0,
                  "data": [
                    {
                      "id": 0,
                      "name": "string",
                      "modifiedOn": "string",
                      "createdOn": "string",
                      "active": true,
                      "isDefaultCampaign": true,
                      "category": {
                        "id": 0,
                        "name": "string",
                        "active": true
                      },
                      "source": "string",
                      "otherSource": "string",
                      "businessUnit": "string",
                      "medium": "string",
                      "otherMedium": "string",
                      "campaignPhoneNumbers": [
                        "string"
                      ]
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "The request cannot be processed, check validation errors or request format",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                },
                "example": {
                  "type": "string",
                  "title": "string",
                  "status": 0,
                  "traceId": "string",
                  "errors": {},
                  "data": {}
                }
              }
            }
          }
        },
        "security": [
          {
            "apiKeyHeader": [],
            "oauth": [
              "tn.mrk.campaigns:r"
            ]
          }
        ]
      },
      "post": {
        "tags": [
          "Campaigns"
        ],
        "summary": "Creates new campaign",
        "operationId": "Campaigns_Create",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "Tenant ID",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Marketing.V2.CampaignUpsertRequest"
              },
              "example": {
                "name": "string",
                "businessUnitId": 0,
                "dnis": "string",
                "categoryId": 0,
                "active": true,
                "isDefaultCampaign": true,
                "source": "string",
                "medium": "string",
                "otherSource": "string",
                "otherMedium": "string"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The request has succeeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Marketing.V2.CampaignResponse"
                },
                "example": {
                  "id": 0,
                  "name": "string",
                  "modifiedOn": "string",
                  "createdOn": "string",
                  "active": true,
                  "isDefaultCampaign": true,
                  "category": {
                    "id": 0,
                    "name": "string",
                    "active": true
                  },
                  "source": "string",
                  "otherSource": "string",
                  "businessUnit": "string",
                  "medium": "string",
                  "otherMedium": "string",
                  "campaignPhoneNumbers": [
                    "string"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "The request cannot be processed, check validation errors or request format",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                },
                "example": {
                  "type": "string",
                  "title": "string",
                  "status": 0,
                  "traceId": "string",
                  "errors": {},
                  "data": {}
                }
              }
            }
          }
        },
        "security": [
          {
            "apiKeyHeader": [],
            "oauth": [
              "tn.mrk.campaigns:w"
            ]
          }
        ]
      }
    },
    "/tenant/{tenant}/campaigns/{id}": {
      "get": {
        "tags": [
          "Campaigns"
        ],
        "summary": "Gets campaign specified by ID",
        "operationId": "Campaigns_Get",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "tenant",
            "in": "path",
            "description": "Tenant ID",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The request has succeeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Marketing.V2.CampaignResponse"
                },
                "example": {
                  "id": 0,
                  "name": "string",
                  "modifiedOn": "string",
                  "createdOn": "string",
                  "active": true,
                  "isDefaultCampaign": true,
                  "category": {
                    "id": 0,
                    "name": "string",
                    "active": true
                  },
                  "source": "string",
                  "otherSource": "string",
                  "businessUnit": "string",
                  "medium": "string",
                  "otherMedium": "string",
                  "campaignPhoneNumbers": [
                    "string"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "The request cannot be processed, check validation errors or request format",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                },
                "example": {
                  "type": "string",
                  "title": "string",
                  "status": 0,
                  "traceId": "string",
                  "errors": {},
                  "data": {}
                }
              }
            }
          }
        },
        "security": [
          {
            "apiKeyHeader": [],
            "oauth": [
              "tn.mrk.campaigns:r"
            ]
          }
        ]
      },
      "patch": {
        "tags": [
          "Campaigns"
        ],
        "summary": "Updates specified campaign in \"patch\" mode",
        "operationId": "Campaigns_Update",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "tenant",
            "in": "path",
            "description": "Tenant ID",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Marketing.V2.CampaignUpsertRequest"
              },
              "example": {
                "name": "string",
                "businessUnitId": 0,
                "dnis": "string",
                "categoryId": 0,
                "active": true,
                "isDefaultCampaign": true,
                "source": "string",
                "medium": "string",
                "otherSource": "string",
                "otherMedium": "string"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The request has succeeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Marketing.V2.CampaignResponse"
                },
                "example": {
                  "id": 0,
                  "name": "string",
                  "modifiedOn": "string",
                  "createdOn": "string",
                  "active": true,
                  "isDefaultCampaign": true,
                  "category": {
                    "id": 0,
                    "name": "string",
                    "active": true
                  },
                  "source": "string",
                  "otherSource": "string",
                  "businessUnit": "string",
                  "medium": "string",
                  "otherMedium": "string",
                  "campaignPhoneNumbers": [
                    "string"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "The request cannot be processed, check validation errors or request format",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                },
                "example": {
                  "type": "string",
                  "title": "string",
                  "status": 0,
                  "traceId": "string",
                  "errors": {},
                  "data": {}
                }
              }
            }
          }
        },
        "security": [
          {
            "apiKeyHeader": [],
            "oauth": [
              "tn.mrk.campaigns:w"
            ]
          }
        ]
      }
    },
    "/tenant/{tenant}/campaigns/{id}/costs": {
      "get": {
        "tags": [
          "Campaigns"
        ],
        "summary": "Gets a paginated list of campaign costs",
        "operationId": "Campaigns_GetCosts",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "tenant",
            "in": "path",
            "description": "Tenant ID",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "page",
            "in": "query",
            "description": "The logical number of page to return, starting from 1",
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "pageSize",
            "in": "query",
            "description": "How many records to return (50 by default)",
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "includeTotal",
            "in": "query",
            "description": "Whether total count should be returned",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "year",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "month",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "sort",
            "in": "query",
            "description": "Applies sorting by the specified field:\\\n\"?sort=+FieldName\" for ascending order,\\\n\"?sort=-FieldName\" for descending order.\\\n\\\nAvailable fields are: Id, Date (Year + Month)",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The request has succeeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaginatedResponse_Of_Marketing.V2.CampaignCostResponse"
                },
                "example": {
                  "page": 0,
                  "pageSize": 0,
                  "hasMore": true,
                  "totalCount": 0,
                  "data": [
                    {
                      "id": 0,
                      "year": 0,
                      "month": 0,
                      "dailyCost": 0,
                      "campaignId": 0
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "The request cannot be processed, check validation errors or request format",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                },
                "example": {
                  "type": "string",
                  "title": "string",
                  "status": 0,
                  "traceId": "string",
                  "errors": {},
                  "data": {}
                }
              }
            }
          }
        },
        "security": [
          {
            "apiKeyHeader": [],
            "oauth": [
              "tn.mrk.campaigns:r"
            ]
          }
        ]
      }
    },
    "/tenant/{tenant}/email-channel-cost": {
      "get": {
        "tags": [
          "EmailChannelCost"
        ],
        "operationId": "EmailChannelCost_Get",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "Tenant ID",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The request has succeeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Marketing.V2.EmailChannelCostResponse"
                },
                "example": {
                  "totalCost": 0
                }
              }
            }
          },
          "400": {
            "description": "The request cannot be processed, check validation errors or request format",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                },
                "example": {
                  "type": "string",
                  "title": "string",
                  "status": 0,
                  "traceId": "string",
                  "errors": {},
                  "data": {}
                }
              }
            }
          }
        },
        "security": [
          {
            "apiKeyHeader": [],
            "oauth": [
              "tn.mrk.emailchannelcost:r"
            ]
          }
        ]
      }
    },
    "/tenant/{tenant}/sms/optin/import": {
      "post": {
        "tags": [
          "Sms"
        ],
        "summary": "Allows the creation of externally obtained SMS Opt-ins",
        "operationId": "Sms_ImportOptIn",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "description": "Tenant ID",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Marketing.V2.ImportOptInRequest"
              },
              "example": {
                "phoneNumbers": [
                  "string"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The request has succeeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Marketing.V2.ImportOptInResult"
                },
                "example": {
                  "successfulPhoneNumbers": [
                    "string"
                  ],
                  "invalidPhoneNumbers": [
                    "string"
                  ],
                  "unsuccessfulPhoneNumbers": [
                    "string"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "The request cannot be processed, check validation errors or request format",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                },
                "example": {
                  "type": "string",
                  "title": "string",
                  "status": 0,
                  "traceId": "string",
                  "errors": {},
                  "data": {}
                }
              }
            }
          }
        },
        "security": [
          {
            "apiKeyHeader": [],
            "oauth": [
              "tn.mrk.sms:w"
            ]
          }
        ]
      }
    }
  },
  "components": {
    "schemas": {
      "PaginatedResponse_Of_Marketing.V2.CampaignCategoryResponse": {
        "required": [
          "page",
          "pageSize",
          "hasMore",
          "data"
        ],
        "type": "object",
        "properties": {
          "page": {
            "type": "integer",
            "description": "From which page this output has started",
            "format": "int32"
          },
          "pageSize": {
            "type": "integer",
            "description": "Page size for this query (i.e. how many records were requested to return)",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean",
            "description": "True if there are more records in the query than returned in this result"
          },
          "totalCount": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Total count of records for this query (can optionally be populated)",
            "format": "int32"
          },
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Marketing.V2.CampaignCategoryResponse"
            },
            "description": "The collection of result items, will never have more than PageSize items"
          }
        },
        "additionalProperties": false,
        "description": "Represents paginated API response."
      },
      "Marketing.V2.CampaignCategoryResponse": {
        "required": [
          "id",
          "name",
          "active",
          "type",
          "createdOn",
          "modifiedOn"
        ],
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64"
          },
          "name": {
            "type": "string"
          },
          "active": {
            "type": "boolean"
          },
          "type": {
            "$ref": "#/components/schemas/Marketing.V2.CampaignCategoryType"
          },
          "createdOn": {
            "type": "string",
            "format": "date-time"
          },
          "modifiedOn": {
            "type": "string",
            "format": "date-time"
          }
        },
        "additionalProperties": false
      },
      "Marketing.V2.CampaignCategoryType": {
        "enum": [
          "Regular",
          "GoogleHomeServices"
        ],
        "type": "string",
        "description": "",
        "x-enumNames": [
          "Regular",
          "GoogleHomeServices"
        ]
      },
      "ApiErrorResponse": {
        "required": [
          "type",
          "title",
          "status",
          "traceId",
          "errors",
          "data"
        ],
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "description": "A URI reference that identifies the problem type"
          },
          "title": {
            "type": "string",
            "description": "A short, human-readable summary of the problem type"
          },
          "status": {
            "type": "integer",
            "description": "The HTTP status code generated by server",
            "format": "int32"
          },
          "traceId": {
            "type": "string",
            "description": "Internal trace ID for advanced diagnostics"
          },
          "errors": {
            "type": "object",
            "additionalProperties": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "description": "Provides more details about errors occurred, which can potentially be used for visual display"
          },
          "data": {
            "type": "object",
            "additionalProperties": {},
            "description": "Provides additional data, intended for programmatical usage"
          }
        },
        "additionalProperties": false,
        "description": "Detailed error response, following RFC 7807 recommendations (https://tools.ietf.org/html/rfc7807)."
      },
      "ModificationResponse": {
        "required": [
          "id"
        ],
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "description": "The ID of created/updated object",
            "format": "int64"
          }
        },
        "additionalProperties": false,
        "description": "Default response when creating object with a new ID, or updating object by specified ID."
      },
      "Marketing.V2.CampaignCategoryUpdateRequest": {
        "required": [
          "name"
        ],
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "active": {
            "type": [
              "boolean",
              "null"
            ]
          }
        },
        "additionalProperties": false
      },
      "Marketing.V2.CampaignCategoryCreateRequest": {
        "required": [
          "name"
        ],
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          }
        },
        "additionalProperties": false
      },
      "PaginatedResponse_Of_Marketing.V2.CampaignCostResponse": {
        "required": [
          "page",
          "pageSize",
          "hasMore",
          "data"
        ],
        "type": "object",
        "properties": {
          "page": {
            "type": "integer",
            "description": "From which page this output has started",
            "format": "int32"
          },
          "pageSize": {
            "type": "integer",
            "description": "Page size for this query (i.e. how many records were requested to return)",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean",
            "description": "True if there are more records in the query than returned in this result"
          },
          "totalCount": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Total count of records for this query (can optionally be populated)",
            "format": "int32"
          },
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Marketing.V2.CampaignCostResponse"
            },
            "description": "The collection of result items, will never have more than PageSize items"
          }
        },
        "additionalProperties": false,
        "description": "Represents paginated API response."
      },
      "Marketing.V2.CampaignCostResponse": {
        "required": [
          "id",
          "year",
          "month",
          "dailyCost",
          "campaignId"
        ],
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64"
          },
          "year": {
            "type": "integer",
            "format": "int32"
          },
          "month": {
            "type": "integer",
            "format": "int32"
          },
          "dailyCost": {
            "type": "number",
            "format": "decimal"
          },
          "campaignId": {
            "type": "integer",
            "format": "int64"
          }
        },
        "additionalProperties": false
      },
      "Marketing.V2.CreateCampaignCostRequest": {
        "required": [
          "campaignId",
          "year",
          "month",
          "dailyCost"
        ],
        "type": "object",
        "properties": {
          "campaignId": {
            "type": "integer",
            "format": "int64"
          },
          "year": {
            "type": "integer",
            "format": "int32"
          },
          "month": {
            "type": "integer",
            "format": "int32"
          },
          "dailyCost": {
            "type": "number",
            "format": "decimal"
          }
        },
        "additionalProperties": false
      },
      "Marketing.V2.UpdateCampaignCostRequest": {
        "required": [
          "dailyCost"
        ],
        "type": "object",
        "properties": {
          "dailyCost": {
            "type": "number",
            "format": "decimal"
          }
        },
        "additionalProperties": false
      },
      "Marketing.V2.CampaignCostsSummaryResponse": {
        "required": [
          "items"
        ],
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Marketing.V2.CampaignCostsSummaryItem"
            }
          }
        },
        "additionalProperties": false
      },
      "Marketing.V2.CampaignCostsSummaryItem": {
        "required": [
          "campaignId",
          "campaignName"
        ],
        "type": "object",
        "properties": {
          "campaignId": {
            "type": "integer",
            "format": "int64"
          },
          "campaignName": {
            "type": "string"
          },
          "totalCost": {
            "type": [
              "number",
              "null"
            ],
            "format": "decimal"
          }
        },
        "additionalProperties": false
      },
      "PaginatedResponse_Of_Marketing.V2.CampaignResponse": {
        "required": [
          "page",
          "pageSize",
          "hasMore",
          "data"
        ],
        "type": "object",
        "properties": {
          "page": {
            "type": "integer",
            "description": "From which page this output has started",
            "format": "int32"
          },
          "pageSize": {
            "type": "integer",
            "description": "Page size for this query (i.e. how many records were requested to return)",
            "format": "int32"
          },
          "hasMore": {
            "type": "boolean",
            "description": "True if there are more records in the query than returned in this result"
          },
          "totalCount": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Total count of records for this query (can optionally be populated)",
            "format": "int32"
          },
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Marketing.V2.CampaignResponse"
            },
            "description": "The collection of result items, will never have more than PageSize items"
          }
        },
        "additionalProperties": false,
        "description": "Represents paginated API response."
      },
      "Marketing.V2.CampaignResponse": {
        "required": [
          "id",
          "name",
          "modifiedOn",
          "createdOn",
          "active"
        ],
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64"
          },
          "name": {
            "type": "string"
          },
          "modifiedOn": {
            "type": "string",
            "format": "date-time"
          },
          "createdOn": {
            "type": "string",
            "format": "date-time"
          },
          "active": {
            "type": "boolean"
          },
          "isDefaultCampaign": {
            "type": [
              "boolean",
              "null"
            ]
          },
          "category": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Marketing.V2.CampaignResponseCategory"
              },
              {
                "type": "null"
              }
            ]
          },
          "source": {
            "type": [
              "string",
              "null"
            ]
          },
          "otherSource": {
            "type": [
              "string",
              "null"
            ]
          },
          "businessUnit": {
            "type": [
              "string",
              "null"
            ]
          },
          "medium": {
            "type": [
              "string",
              "null"
            ]
          },
          "otherMedium": {
            "type": [
              "string",
              "null"
            ]
          },
          "campaignPhoneNumbers": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "string"
            }
          }
        },
        "additionalProperties": false
      },
      "Marketing.V2.CampaignResponseCategory": {
        "required": [
          "id",
          "name",
          "active"
        ],
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64"
          },
          "name": {
            "type": "string"
          },
          "active": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "ActiveRequestArg": {
        "enum": [
          "True",
          "Any",
          "False"
        ],
        "type": "string",
        "description": "Represents possible HTTP query argument values, when applying filters based on active status.",
        "x-enumNames": [
          "True",
          "Any",
          "False"
        ]
      },
      "Marketing.V2.CampaignUpsertRequest": {
        "type": "object",
        "properties": {
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Campaign name. Required when creating. On update, if omitted or null, the current name is kept."
          },
          "businessUnitId": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Business unit ID. On update, if omitted or null, the current business unit is kept; 0 removes it.",
            "format": "int64"
          },
          "dnis": {
            "type": [
              "string",
              "null"
            ]
          },
          "categoryId": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Campaign category ID. On update, if omitted or null, the current category is kept; 0 removes it.",
            "format": "int64"
          },
          "active": {
            "type": [
              "boolean",
              "null"
            ],
            "description": "Campaign active status. On update, if omitted or null, the current status is kept."
          },
          "isDefaultCampaign": {
            "type": [
              "boolean",
              "null"
            ]
          },
          "source": {
            "type": [
              "string",
              "null"
            ]
          },
          "medium": {
            "type": [
              "string",
              "null"
            ]
          },
          "otherSource": {
            "type": [
              "string",
              "null"
            ]
          },
          "otherMedium": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "additionalProperties": false
      },
      "Marketing.V2.EmailChannelCostResponse": {
        "type": "object",
        "properties": {
          "totalCost": {
            "type": [
              "number",
              "null"
            ],
            "format": "decimal"
          }
        },
        "additionalProperties": false
      },
      "Marketing.V2.ImportOptInResult": {
        "required": [
          "successfulPhoneNumbers",
          "invalidPhoneNumbers",
          "unsuccessfulPhoneNumbers"
        ],
        "type": "object",
        "properties": {
          "successfulPhoneNumbers": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "invalidPhoneNumbers": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "unsuccessfulPhoneNumbers": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "additionalProperties": false
      },
      "Marketing.V2.ImportOptInRequest": {
        "required": [
          "phoneNumbers"
        ],
        "type": "object",
        "properties": {
          "phoneNumbers": {
            "minItems": 1,
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "additionalProperties": false
      }
    },
    "securitySchemes": {
      "apiKeyHeader": {
        "type": "apiKey",
        "name": "ST-App-Key",
        "in": "header",
        "description": "ServiceTitan App Key Header"
      },
      "oauth": {
        "type": "oauth2",
        "description": "OAuth 2.0 Client Credentials Flow",
        "flows": {
          "clientCredentials": {
            "tokenUrl": "https://auth.servicetitan.io/connect/token",
            "scopes": {
              "tn.mrk.categories:r": "Marketing → Campaign Categories (Read)",
              "tn.mrk.categories:w": "Marketing → Campaign Categories (Write)",
              "tn.mrk.costs:r": "Marketing → Campaign Costs (Read)",
              "tn.mrk.costs:w": "Marketing → Campaign Costs (Write)",
              "tn.mrk.campaigncostsummary:r": "Marketing → Campaign Cost Summary (Read)",
              "tn.mrk.campaigns:r": "Marketing → Campaigns (Read)",
              "tn.mrk.campaigns:w": "Marketing → Campaigns (Write)",
              "tn.mrk.emailchannelcost:r": "Marketing → Email Channel Cost (Read)",
              "tn.mrk.sms:w": "Marketing → SMS (Write)"
            }
          }
        }
      }
    }
  }
}