# Spara en version av en rapportmall med vägledning

Kanonisk URL: https://sosoapi.ai/sv/docs/mcp/save-report-template

`sosoapi_save_report_template`

Spara en version av en rapportmall med vägledning. Använder den uttryckligen angivna och granskade datamängden och versionen; källan uppdateras inte automatiskt. Indata för rendering kan skickas via en pipe till sosoapi report render --output FILE.

## Profiler och transporter

Profiler: full

Transporter: stdio, http

Välj core eller full för att styra vilka verktyg klienten ser; detta ändrar inte dess behörigheter. Lokal filuppladdning kräver stdio och är inte tillgänglig via HTTP. Ange SOSOAPI_OUTPUT_SCHEMAS=1 för att inkludera utdatascheman vid identifiering. Verktygen returnerar strukturerade resultat med eller utan inställningen.

## Behörigheter och sidoeffekter

Annoteringar hjälper klienter att beskriva ett verktyg. Varje anrop kontrollerar fortfarande användarens autentisering, roll, resursåtkomst och tilldelade funktionsbehörigheter.

```json
{
  "readOnlyHint": false,
  "destructiveHint": false,
  "idempotentHint": true,
  "openWorldHint": false
}
```

`/analytics-api/reporting/templates/save` — agent:operate; synchronous_http_response

## Indatafält

```json
{
  "type": "object",
  "properties": {
    "workspace_id": {
      "type": "string",
      "format": "uuid"
    },
    "template": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "format": "uuid"
        },
        "version": {
          "type": "integer",
          "minimum": 1,
          "maximum": 1000000
        },
        "name": {
          "type": "string",
          "minLength": 1,
          "maxLength": 100
        },
        "format": {
          "type": "string",
          "enum": [
            "pptx",
            "docx",
            "xlsx"
          ]
        },
        "sourceBase64": {
          "type": "string",
          "maxLength": 12582912,
          "pattern": "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$"
        },
        "sourceSha256": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        },
        "mappings": {
          "type": "object",
          "additionalProperties": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "type": "string",
                    "enum": [
                      "text"
                    ]
                  },
                  "value": {
                    "type": "string",
                    "maxLength": 2000
                  }
                },
                "required": [
                  "kind",
                  "value"
                ],
                "additionalProperties": false
              },
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "type": "string",
                    "enum": [
                      "selection"
                    ]
                  },
                  "field": {
                    "type": "string",
                    "enum": [
                      "accounts",
                      "period",
                      "timezone",
                      "platforms",
                      "dataset",
                      "reviewed",
                      "coverage"
                    ]
                  }
                },
                "required": [
                  "kind",
                  "field"
                ],
                "additionalProperties": false
              },
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "type": "string",
                    "enum": [
                      "metric"
                    ]
                  },
                  "platform": {
                    "type": "string",
                    "enum": [
                      "facebook",
                      "instagram",
                      "threads",
                      "youtube"
                    ]
                  },
                  "key": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 150
                  },
                  "unit": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100
                  },
                  "grain": {
                    "type": "string",
                    "enum": [
                      "post",
                      "account"
                    ]
                  },
                  "measurementKind": {
                    "type": "string",
                    "enum": [
                      "lifetime",
                      "snapshot",
                      "period",
                      "unknown"
                    ]
                  },
                  "accountId": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "providerResourceId": {
                    "anyOf": [
                      {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 512
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "sourcePath": {
                    "type": "string",
                    "maxLength": 2000
                  },
                  "requestId": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "uuid"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                },
                "required": [
                  "kind",
                  "platform",
                  "key",
                  "unit",
                  "grain",
                  "measurementKind"
                ],
                "additionalProperties": false
              },
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "type": "string",
                    "enum": [
                      "formula"
                    ]
                  },
                  "id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "version": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 1000000
                  }
                },
                "required": [
                  "kind",
                  "id",
                  "version"
                ],
                "additionalProperties": false
              },
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "type": "string",
                    "enum": [
                      "table"
                    ]
                  },
                  "source": {
                    "type": "string",
                    "enum": [
                      "measurements",
                      "formulas"
                    ]
                  },
                  "limit": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 100
                  }
                },
                "required": [
                  "kind",
                  "source",
                  "limit"
                ],
                "additionalProperties": false
              },
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "type": "string",
                    "enum": [
                      "chart"
                    ]
                  },
                  "source": {
                    "type": "string",
                    "enum": [
                      "publication_by_platform"
                    ]
                  }
                },
                "required": [
                  "kind",
                  "source"
                ],
                "additionalProperties": false
              }
            ]
          }
        }
      },
      "required": [
        "id",
        "version",
        "name",
        "format",
        "sourceBase64",
        "sourceSha256",
        "mappings"
      ],
      "additionalProperties": false
    },
    "expected_version": {
      "anyOf": [
        {
          "type": "integer",
          "minimum": 1,
          "maximum": 1000000
        },
        {
          "type": "null"
        }
      ]
    },
    "mutation_id": {
      "type": "string",
      "format": "uuid"
    }
  },
  "required": [
    "workspace_id",
    "template",
    "expected_version",
    "mutation_id"
  ],
  "additionalProperties": false
}
```

## Strukturerat resultat

Detta schema beskriver structuredContent i ett lyckat verktygsresultat. MCP-svaret innehåller även content och kan ange isError när ett anrop misslyckas. För publicering ska du läsa inläggets slutresultat i stället för att tolka en accepterad begäran eller ett textsvar som bekräftelse. Den länkade API-åtgärden förklarar behörigheter och regler för nya försök.

```json
{
  "type": "object",
  "properties": {
    "contractVersion": {
      "type": "string",
      "const": "analytics-template/v1"
    },
    "workspaceId": {
      "type": "string",
      "format": "uuid"
    },
    "id": {
      "type": "string",
      "format": "uuid"
    },
    "version": {
      "type": "integer",
      "minimum": 1,
      "maximum": 1000000
    },
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 100
    },
    "format": {
      "type": "string",
      "enum": [
        "pptx",
        "docx",
        "xlsx"
      ]
    },
    "sourceBase64": {
      "type": "string",
      "maxLength": 12582912,
      "pattern": "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$"
    },
    "sourceSha256": {
      "type": "string",
      "pattern": "^[a-f0-9]{64}$"
    },
    "mappings": {
      "type": "object",
      "propertyNames": {
        "type": "string",
        "pattern": "^[A-Za-z][A-Za-z0-9_.-]{0,63}$"
      },
      "additionalProperties": {
        "oneOf": [
          {
            "type": "object",
            "properties": {
              "kind": {
                "type": "string",
                "const": "text"
              },
              "value": {
                "type": "string",
                "maxLength": 2000
              }
            },
            "required": [
              "kind",
              "value"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "kind": {
                "type": "string",
                "const": "selection"
              },
              "field": {
                "type": "string",
                "enum": [
                  "accounts",
                  "period",
                  "timezone",
                  "platforms",
                  "dataset",
                  "reviewed",
                  "coverage"
                ]
              }
            },
            "required": [
              "kind",
              "field"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "kind": {
                "type": "string",
                "const": "metric"
              },
              "platform": {
                "type": "string",
                "enum": [
                  "facebook",
                  "instagram",
                  "threads",
                  "youtube"
                ]
              },
              "key": {
                "type": "string",
                "minLength": 1,
                "maxLength": 150
              },
              "unit": {
                "type": "string",
                "minLength": 1,
                "maxLength": 100
              },
              "grain": {
                "type": "string",
                "enum": [
                  "post",
                  "account"
                ]
              },
              "measurementKind": {
                "type": "string",
                "enum": [
                  "lifetime",
                  "snapshot",
                  "period",
                  "unknown"
                ]
              },
              "accountId": {
                "type": "string",
                "format": "uuid"
              },
              "providerResourceId": {
                "anyOf": [
                  {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 512
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "sourcePath": {
                "type": "string",
                "maxLength": 2000
              },
              "requestId": {
                "anyOf": [
                  {
                    "type": "string",
                    "format": "uuid"
                  },
                  {
                    "type": "null"
                  }
                ]
              }
            },
            "required": [
              "kind",
              "platform",
              "key",
              "unit",
              "grain",
              "measurementKind"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "kind": {
                "type": "string",
                "const": "formula"
              },
              "id": {
                "type": "string",
                "format": "uuid"
              },
              "version": {
                "type": "integer",
                "minimum": 1,
                "maximum": 1000000
              }
            },
            "required": [
              "kind",
              "id",
              "version"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "kind": {
                "type": "string",
                "const": "table"
              },
              "source": {
                "type": "string",
                "enum": [
                  "measurements",
                  "formulas"
                ]
              },
              "limit": {
                "type": "integer",
                "minimum": 1,
                "maximum": 100
              }
            },
            "required": [
              "kind",
              "source",
              "limit"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "kind": {
                "type": "string",
                "const": "chart"
              },
              "source": {
                "type": "string",
                "const": "publication_by_platform"
              }
            },
            "required": [
              "kind",
              "source"
            ],
            "additionalProperties": false
          }
        ]
      }
    },
    "createdAt": {
      "type": "string",
      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$",
      "format": "date-time"
    }
  },
  "required": [
    "contractVersion",
    "workspaceId",
    "id",
    "version",
    "name",
    "format",
    "sourceBase64",
    "sourceSha256",
    "mappings",
    "createdAt"
  ],
  "$schema": "http://json-schema.org/draft-07/schema#",
  "additionalProperties": false
}
```

## Exempel på verktygsanrop

Exemplen använder fiktiva värden som kontrollerats mot schemana. Ersätt ID:n med sådana du får använda, medier med färdiga mediefiler och datum med din bekräftade publiceringstid. Kontrollera kontots behörighet före en skrivning. Denna sida skickar inga API-anrop.

```json
{
  "name": "sosoapi_save_report_template",
  "arguments": {
    "workspace_id": "11111111-1111-4111-8111-111111111111",
    "template": {
      "id": "11111111-1111-4111-8111-111111111111",
      "version": 1,
      "name": "example",
      "format": "pptx",
      "sourceBase64": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
      "sourceSha256": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
      "mappings": {}
    },
    "expected_version": null,
    "mutation_id": "11111111-1111-4111-8111-111111111111"
  }
}
```

structuredContent

```json
{
  "contractVersion": "analytics-template/v1",
  "workspaceId": "11111111-1111-4111-8111-111111111111",
  "id": "11111111-1111-4111-8111-111111111111",
  "version": 1,
  "name": "example",
  "format": "pptx",
  "sourceBase64": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "sourceSha256": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "mappings": {},
  "createdAt": "2099-01-15T09:00:00Z"
}
```

## Underliggande API-åtgärder

- [/analytics-api/reporting/templates/save](https://sosoapi.ai/sv/docs/api/analytics-api-reporting-templates-save)
