> ## Documentation Index
> Fetch the complete documentation index at: https://docs.superoffice.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Set Document Template Stream

> Store a document template from its stream.

Since there is a potential for a name conflict (the file name stored by the document entity earlier may prove to be invalid), the (possibly amended) document entity is returned. The client should not assume that any earlier, cached entity information is valid.
NsApiSlow threshold: 5000 ms.



## OpenAPI

````yaml /openapi/agent/openapi-v3-ListAgent.json post /api/v1/Agents/List/SetDocumentTemplateStream
openapi: 3.0.0
info:
  version: v1-Agents
  title: SuperOffice Agent API v1
  description: SuperOffice Agent API - ListAgent
  contact:
    name: SuperOffice DevNet
    url: https://docs.superoffice.com/en/api/index.html
    email: sdk@superoffice.com
servers:
  - url: http://localhost:56350
  - url: https://localhost:56350
security: []
tags: []
externalDocs:
  description: >-
    The SuperOffice DevNet Community has more documentation, examples, and
    discussion forums.
  url: https://community.superoffice.com/en/developer/
paths:
  /api/v1/Agents/List/SetDocumentTemplateStream:
    post:
      tags:
        - List_Agent
      summary: Set Document Template Stream
      description: "Store a document template from its stream.\n\nSince there is a potential for a name conflict (the file name stored by the document entity earlier may prove to be invalid), the (possibly amended) document entity is returned. The client should not assume that any earlier, cached entity information is valid.\r\nNsApiSlow threshold: 5000 ms."
      operationId: v1ListAgent_SetDocumentTemplateStream
      parameters:
        - name: $select
          in: query
          description: >-
            Optional comma separated list of properties to include in the
            result. Other fields are then nulled out to reduce payload size:
            "Name,department,category". Default = show all fields.
          required: false
          schema:
            type: string
        - name: Accept-Language
          in: header
          description: >-
            Convert string references and multi-language values into a specified
            language (iso2) code.
          required: false
          schema:
            type: string
        - name: SO-Language
          in: header
          description: >-
            Convert string references and multi-language values into a specified
            language (iso2) code. Overrides Accept-Language value.
          required: false
          schema:
            type: string
        - name: SO-Culture
          in: header
          description: >-
            Number, date formatting in a specified culture (iso2 language) code.
            Partially overrides SO-Language/Accept-Language value. Ignored if no
            Language set.
          required: false
          schema:
            type: string
        - name: SO-TimeZone
          in: header
          description: >-
            Specify the timezone code that you would like date/time responses
            converted to.
          required: false
          schema:
            type: string
        - name: SO-AppToken
          in: header
          description: >-
            The application token that identifies the partner app. Used when
            calling Online WebAPI from a server.
          required: false
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: >-
                #/components/schemas/SuperOffice.WebApi.v1.Carriers.ListCarriers.SetDocumentTemplateStreamRequest
          text/json:
            schema:
              $ref: >-
                #/components/schemas/SuperOffice.WebApi.v1.Carriers.ListCarriers.SetDocumentTemplateStreamRequest
          application/xml:
            schema:
              $ref: >-
                #/components/schemas/SuperOffice.WebApi.v1.Carriers.ListCarriers.SetDocumentTemplateStreamRequest
          text/xml:
            schema:
              $ref: >-
                #/components/schemas/SuperOffice.WebApi.v1.Carriers.ListCarriers.SetDocumentTemplateStreamRequest
          application/x-www-form-urlencoded:
            schema:
              $ref: >-
                #/components/schemas/SuperOffice.WebApi.v1.Carriers.ListCarriers.SetDocumentTemplateStreamRequest
          application/json-patch+json:
            schema:
              $ref: >-
                #/components/schemas/SuperOffice.WebApi.v1.Carriers.ListCarriers.SetDocumentTemplateStreamRequest
          application/merge-patch+json:
            schema:
              $ref: >-
                #/components/schemas/SuperOffice.WebApi.v1.Carriers.ListCarriers.SetDocumentTemplateStreamRequest
        description: DocumentTemplateEntity, Stream, LanguageCode, PluginId
        required: true
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/SuperOffice.CRM.Services.DocumentTemplateEntity
            text/json:
              schema:
                $ref: >-
                  #/components/schemas/SuperOffice.CRM.Services.DocumentTemplateEntity
            application/xml:
              schema:
                $ref: >-
                  #/components/schemas/SuperOffice.CRM.Services.DocumentTemplateEntity
            text/xml:
              schema:
                $ref: >-
                  #/components/schemas/SuperOffice.CRM.Services.DocumentTemplateEntity
            application/json-patch+json:
              schema:
                $ref: >-
                  #/components/schemas/SuperOffice.CRM.Services.DocumentTemplateEntity
            application/merge-patch+json:
              schema:
                $ref: >-
                  #/components/schemas/SuperOffice.CRM.Services.DocumentTemplateEntity
      security:
        - SuperOffice_Password: []
          SuperId_Authentication: []
components:
  schemas:
    SuperOffice.WebApi.v1.Carriers.ListCarriers.SetDocumentTemplateStreamRequest:
      description: >-
        SetDocumentTemplateStream: Store a document template from its stream.
        Since there is a potential for a name conflict (the file name stored by
        the document entity earlier may prove to be invalid), the (possibly
        amended) document entity is returned. The client should not assume that
        any earlier, cached entity information is valid.
      type: object
      properties:
        DocumentTemplateEntity:
          $ref: '#/components/schemas/SuperOffice.CRM.Services.DocumentTemplateEntity'
        Stream:
          format: byte
          type: string
        LanguageCode:
          type: string
        PluginId:
          format: int32
          type: integer
    SuperOffice.CRM.Services.DocumentTemplateEntity:
      description: "The template a document is based on is stored in the SO_arc\\template folder on the server. This will return the name as displayed in the GUI, and not the physical document name, of the template the document object is based on.\r\n<para />\r\nCarrier object for DocumentTemplateEntity.\r\nServices for the DocumentTemplateEntity Carrier is available from the <see cref=\"T:SuperOffice.CRM.Services.IListAgent\">List Agent</see>."
      type: object
      properties:
        DocumentTemplateId:
          format: int32
          description: Primary key
          type: integer
        Name:
          description: The template list item
          type: string
        Tooltip:
          description: Tooltip or other description
          type: string
        SaveInDb:
          format: int32
          description: 1 = save document records in DB; otherwise not.
          type: integer
        Filename:
          description: >-
            Relative to TemplatePath, or extref for other document plugins. i.e
            URL or full path.
          type: string
        DefaultOref:
          description: Processed via tag substitution to give document reference
          type: string
        RecordType:
          description: >-
            1 = app, 2 = doc, 3 = email, 4 = fax, 5 = phone, 6 = todo - see
            EAppntRecordTypes
          enum:
            - Unknown
            - Appointment
            - Document
            - Email
            - Fax
            - Phone
            - Todo
            - MergeDraft
            - MergeFinal
            - SavedReport
          type: string
        Deleted:
          description: True if deleted
          type: boolean
        Direction:
          description: 1 = incoming, 2 = outgoing, see EAppntDirection
          enum:
            - Unknown
            - Incoming
            - Outgoing
            - SaintAll
          type: string
        AutoeventId:
          format: int32
          description: >-
            Which document plugin is responsible for the documents generated
            from this template
          type: integer
        IntentId:
          format: int32
          description: What is the intention of this document (used by SAINT)
          type: integer
        IsDefaultPublished:
          description: Published to external persons
          type: boolean
        Rank:
          format: int32
          description: Rank order
          type: integer
        LoadTemplateFromPlugin:
          format: int32
          description: Which document plugin is responsible for this template's contents
          type: integer
        MimeType:
          description: The mime type
          type: string
        IsInUseInGuides:
          description: True if the template is in use in a project or sales guide
          type: boolean
        DocumentTypeKey:
          format: int32
          description: >-
            The document type to use when creating a blank document.
            Plugin-specific. Used when not creating template from a local file.
          type: integer
        QuoteDocType:
          description: The role this document plays in the Quote system, if any
          enum:
            - None
            - MailBody
            - MainDocument
            - QuoteLines
            - ConfirmationMailBody
            - ConfirmationLines
          type: string
        PrivacyDocType:
          description: >-
            Indicator that this document template has a functional role, related
            to privacy/GDPR
          enum:
            - None
            - PersonRegistered
          type: string
        EmailSubject:
          description: Subject to use if document template is an email.
          type: string
        IncludeSignature:
          description: >-
            True if the email signature should be added in bottom of mail if
            this an email template
          type: boolean
        ShowCurrents:
          description: >-
            True if when using this template there should be shown a place for
            editing current choices of person, compant, sale, project etc
          type: boolean
        SenderEmailMode:
          description: >-
            If email template, when DocType is Privacy or quote email, it is
            possible to make sender address like our contact, or our support
            contact, or always one address
          enum:
            - UseDefaultSender
            - UseOurContact
            - UseSupportContact
            - UseLoggedInUser
          type: string
        SenderEmailAddress:
          description: >-
            If email template, default senderaddress when template is of type
            quote email or privacy email.
          type: string
        InvitationDocType:
          description: >-
            Type for sending email meeting invitation. Not an invitation type
            template = 0, New = 1, Changed = 2, Cancelled = 3
          enum:
            - None
            - New
            - Changed
            - Cancelled
          type: string
        TableRight:
          $ref: '#/components/schemas/SuperOffice.CRM.Security.TableRight'
        FieldProperties:
          description: >-
            Field property dictionary mapping field names to field access
            rights.
          type: object
          additionalProperties:
            $ref: '#/components/schemas/SuperOffice.CRM.Security.FieldProperty'
    SuperOffice.CRM.Security.TableRight:
      description: "Wraps a table right together with an explanatory reason.\r\nCode can indicate why access is restricted."
      type: object
      properties:
        Mask:
          type: string
        Reason:
          type: string
    SuperOffice.CRM.Security.FieldProperty:
      description: >-
        Class holding properties like field length, field type about a field in
        the carrier.
      type: object
      properties:
        FieldRight:
          $ref: '#/components/schemas/SuperOffice.CRM.Security.FieldRight'
        FieldType:
          type: string
        FieldLength:
          format: int32
          description: ''
          type: integer
    SuperOffice.CRM.Security.FieldRight:
      description: "Wraps the field right together with an explanatory reason.\r\nAlso adds logical operators to the field rights so that they can be easily combined."
      type: object
      properties:
        Mask:
          type: string
        Reason:
          type: string

````

## Related topics

- [Add a document template](/en/api/web-services/howto/document/rest-add-document-template.md)
- [SuperOffice.WebApi.Data.List SetDocumentTemplateStreamRequest](/en/api/reference/webapi/SuperOffice.WebApi.Data.List_SetDocumentTemplateStreamRequest.md)
- [NSListAgent](/en/automation/crmscript/reference/CRMScript.NetServer.NSListAgent.md)
- [SuperOffice.WebApi.Agents.IListAgent](/en/api/reference/webapi/SuperOffice.WebApi.Agents.IListAgent.md)
- [SuperOffice.WebApi.Agents.ListAgent](/en/api/reference/webapi/SuperOffice.WebApi.Agents.ListAgent.md)
- [Set Template Stream](/en/api/reference/restful/agent/document_agent/set-template-stream.md)
