API Operations

Documentation for document_types

show

Overview

Allows to retrieve the details of a single document type accessible by the user.

As all others, this method requires authentication. To understand how to retrieve the authentication token, refer to the Login documentation page.

Request

endpoint
/api/v1/document_type/[id].[format]
http method
GET

id is the dc_identifier obtained with the index api call.

format must be either json or xml

Required Parameters

entity_id
ID of the entity whom document type you want to show, as obtained by the entities/index api call.

Optional Parameters

None

Response

Response is a list of the attributes of the document type and the list of the meta types that defines it.

dc_identifier
unique identifier of this document type
name
name of the document type
dc_version
version of this document type
variant
the active variant of this document type for the specified entity
required_attributes
Array of attributes that are always required (for any document type)
meta_type_relations
Array of the meta types allowed by this document type

Each entry in meta_type_relations array contains the following attributes:

is_required
Bool flag that indicates if this meta type is required by this document type (possible values: true or false)
meta_type
attributes of this meta type

The meta_type element contains the following attributes:

name
Name of this meta type (used as a metadata key in document creation)
label
Pretty name given to the meta type by the user
dc_identifier
unique identifier of this meta type
datatype
indicates the expected type of this meta type, can be one of the following: "string", "text", "integer", "currency", "date", "boolean", "enumeration"
valid_values
If datatype is "enumeration" here appears a list of the allowed values for this meta type. Otherwise this field has no meaning

This is a sample response in JSON format:

{"document_type":
  {
    "dc_identifier":"DT:00103",
    "name":"attachment",
    "dc_version":"1",
    "variant":"V000",
    "required_attributes":["dc_subject","dc_title","dc_description","is_private"],
    "meta_type_relations":
      [
        {"meta_type":
          {"name":"field1","label":"Field 1","dc_identifier":"DT:00138","datatype":"string","valid_values":null},
          "is_required":false
        },
        {"meta_type":
          {"name":"field2","label":"Field 2","dc_identifier":"DT:00136","datatype":"date","valid_values":null},
          "is_required":false
        },
        {"meta_type":
          {"name":"field3","label":"Field 3","dc_identifier":"DT:00155","datatype":"text","valid_values":null},
          "is_required":false
        },
        {"meta_type":
          {"name":"field4","label":"Field 4","dc_identifier":"DT:00156","datatype":"integer","valid_values":null},
          "is_required":false
        },
        {"meta_type":
          {"name":"field5","label":"Field 5","dc_identifier":"DT:00157","datatype":"currency","valid_values":null},
          "is_required":false
        },
        {"meta_type":
          {"name":"field6","label":"Field 6","dc_identifier":"DT:00158","datatype":"boolean","valid_values":null},
          "is_required":false
        },
        {"meta_type":
          {"name":"enum","label":"Enum","dc_identifier":"DT:00159","datatype":"enumeration","valid_values":["val1","val2"]},
          "is_required":false
        }
      ]
    }
  }
        

This is a sample response in XML format:

<?xml version="1.0" encoding="UTF-8"?>
<document-type>
  <dc-identifier>DT:00103</dc-identifier>
  <name>attachment</name>
  <dc-version>1</dc-version>
  <variant>V000</variant>
  <required-attributes type="array">
    <required-attribute>dc_subject</required-attribute>
    <required-attribute>dc_title</required-attribute>
    <required-attribute>dc_description</required-attribute>
    <required-attribute>is_private</required-attribute>
  </required-attributes>
  <meta-type-relations type="array">
    <meta-type-relation>
      <meta-type>
        <name>field1</name>
        <label>Field 1</label>
        <dc-identifier>DT:00138</dc-identifier>
        <datatype>string</datatype>
        <valid-values nil="true"/>
      </meta-type>
      <is-required type="boolean">true</is-required>
    </meta-type-relation>
    <meta-type-relation>
      <meta-type>
        <name>field2</name>
        <label>Field 2</label>
        <dc-identifier>DT:00136</dc-identifier>
        <datatype>date</datatype>
         <valid-values nil="true"/>
      </meta-type>
      <is-required type="boolean">true</is-required>
    </meta-type-relation>
    <meta-type-relation>
      <meta-type>
        <name>field3</name>
        <label>Field 3</label>
        <dc-identifier>DT:00155</dc-identifier>
        <datatype>text</datatype>
        <valid-values nil="true"/>
      </meta-type>
      <is-required type="boolean">true</is-required>
    </meta-type-relation>
    <meta-type-relation>
      <meta-type>
        <name>field4</name>
        <label>Field 4</label>
        <dc-identifier>DT:00156</dc-identifier>
        <datatype>integer</datatype>
        <valid-values nil="true"/>
      </meta-type>
      <is-required type="boolean">true</is-required>
    </meta-type-relation>
    <meta-type-relation>
      <meta-type>
        <name>field5</name>
        <label>Field 5</label>
        <dc-identifier>DT:00157</dc-identifier>
        <datatype>currency</datatype>
        <valid-values nil="true"/>
      </meta-type>
      <is-required type="boolean">true</is-required>
    </meta-type-relation>
    <meta-type-relation>
      <meta-type>
        <name>field6</name>
        <label>Field 6</label>
        <dc-identifier>DT:00158</dc-identifier>
        <datatype>boolean</datatype>
        <valid-values nil="true"/>
      </meta-type>
      <is-required type="boolean">true</is-required>
    </meta-type-relation>
    <meta-type-relation>
      <meta-type>
        <name>field7</name>
        <label>Field 7</label>
        <dc-identifier>DT:00159</dc-identifier>
        <datatype>enumeration</datatype>
        <valid-values type="array">
          <valid-value>val1</valid-value>
          <valid-value>val2</valid-value>
        </valid-values>
      </meta-type>
      <is-required type="boolean">true</is-required>
    </meta-type-relation>
  </meta-type-relations>
</document-type>
        

Examples

In each sample below, you have to substitute values between angular brackets (< and >) with the correct input data.

cUrl

curl -H "Authorization: Token token=<auth_token>" https://www.myo.io/api/v1/document_types/<id<>.json -G -d 'entity_id=<entity_id>'

Ruby (with rest_client)

require 'rest_client'
RestClient::Request.new(:method => "get", :url => 'https://www.myo.io/api/v1/document_types/<id<>.json',
                        :headers => { :accept => :json, :content_type => :json, :'Authorization' => "Token token=<auth_token>"},
                        :payload => {:entity_id => <entity_id>}).execute