api templates create

Matteo Gavagnin edited this page Nov 1, 2012 · 1 revision

Create Template

Create a new Template for a desired category.

POST /api/v1/templates

Params

Param name Required Description
api_token Your Passdock API key
title The title of the Template, must be unique between your templates
description Brief description of the pass, used by the iOS accessibility technologies. Don't try to include all of the data on the pass in its description, just include enough detail to distinguish passes of the same type.
kind_id The category of the Template: 1 for Boarding Pass, 2 for Event Ticket with background and thumbnail, 3 for Coupon, 4 for Store Card, 5 Generic, 6 for Event Ticket with strip.
certificate Certificate to digitally sign each pass and send push notifications.
certificate[data] The certificate blob in format.
icon Icon for the Template, appears when the pass is shown in the lockscreen and as mail attachment.
icon[filename] Name of the file.
icon[data] Content of the image in base64 format.
logo Logo for the Template.
logo[filename] Name of the file.
logo[data] Content of the image in base64 format.
background Background image for the Template, can be set only if the category is Event Ticket ( kind_id = 2).
background[filename] Name of the file.
background[data] Content of the image in base64 format.
thumbnail Thumbnail image for the Template, can be set only if the category is Event Ticket and Generic ( kind_id = 2 or 5).
thumbnail[filename] Name of the file.
thumbnail[data] Content of the image in base64 format.
strip Strip image for the Template, can be set only if the category is Event Ticket, Coupon and Store Card ( kind_id = 3, 4 or 6).
strip[filename] Name of the file.
strip[data] Content of the image in base64 format.
family A JSON dictionary containing the template definition
family[header] An array of fields for the header section, usually of just one element
family[header][field] An Hash for each field
family[header][field][key] The key for the field, invisible on the pass. Is used to create the passes via API as field identifier.
family[header][field][label] The label for the field, usually placed above the value.
family[header][field][value] The value of the field, usually placed below the label.
family[header][field][changeMessage] The change message that will be shown in the lock screen and as notification when the value for the field is changed remotely.
family[header][field][textAlignment] Alignment for the field's contents. Must be one of the following values: PKTextAlignmentLeft , PKTextAlignmentCenter , PKTextAlignmentRight , PKTextAlignmentNatural . This key is not allowed for primary fields.
family[header][field][dateStyle] Style of date to display. Must be one of the following values: PKDateStyleNone , PKDateStyleShort , PKDateStyleMedium , PKDateStyleLong , PKDateStyleFull .
family[header][field][timeStyle] Style of time to display. Must be one of the following values: PKTimeStyleNone , PKTimeStyleShort , PKTimeStyleMedium , PKTimeStyleLong , PKTimeStyleFull .
family[header][field][isRelative] If true , the label 's value is displayed as a relative date; otherwise, it is displayed as an absolute date. The default value is false .
family[header][field][currencyCode] ISO 4217 currency code for the field's value .
family[header][field][numberStyle] Style of number to display. Must be one of the following values: PKNumberStyleDecimal , PKNumberStylePercent , PKNumberStyleScientific , PKNumberStyleSpellOut .
family[visual] Parameters related to the appearance of the pass
family[visual][backgroundColor] Background color of the pass, specified as an CSS-style RGB triple. For example, rgb(23, 187, 82) .
family[visual][foregroundColor] Foreground color of the pass, specified as a CSS-style RGB triple. For example, rgb(100, 10, 110).
family[visual][labelColor] Color of the label text, specified as a CSS-style RGB triple. For example, rgb(255, 255, 255). If omitted, the label color is determined automatically.
family[visual][logoText] Text displayed next to the logo on the pass.
family[visual][suppressStripShine] If true and a strip image is present, the strip image is displayed without a shine effect. The default value is false .
family[primary] An array of fields for the primary section
family[primary][field] Exactly like the field for the header section
family[secondary] An array of fields for the secondary section
family[secondary][field] Exactly like the field for the header section
family[auxiliary] An array of fields for the auxiliary section
family[auxiliary][field] Exactly like the field for the header section
family[back] An array of fields for the back section
family[back][field] Exactly like the field for the header section
family[custom]
family[custom][transitType] Required for boarding passes; otherwise not allowed. Type of transit. Must be one of the following values: PKTransitTypeAir , PKTransitTypeBoat , PKTransitTypeBus , PKTransitTypeGeneric , PKTransitTypeTrain .
family[bar] An hash containing the Bar Section informations
family[bar][message] The message to be put in the 2D code
family[bar][format] Barcode format. Must be one of the following values: PKBarcodeFormatQR , PKBarcodeFormatPDF417 , PKBarcodeFormatAztec .
family[bar][altText] The alternative text that will be put below the bar code.
family[bar][messageEncoding] Text encoding that is used to convert the message from the string representation to a data representation to render the barcode. The value is typically iso-8859-1 , but you may use another encoding that is supported by your barcode scanning infrastructure.
family[relevance] An hash containing the relevance informations like date, time and positions.
family[relevance][locations] Array of locations where the pass will appear on the lockscreen
family[relevance][locations][latitude] Latitude
family[relevance][locations][longitude] Longitude
family[relevance][locations][altitude] Altitude
family[relevance][locations][relevantText] Text that will appear on the lockscreen when the place is reached.
family[relevance][relevantDate] Date and Time when the pass will appear on the lockscreen. Use ISO8601 format.
debug You get in response a JSON with the created object.
errors If an error occurs you get the messages and not only the code.

Supported Formats

json

Success Response:

  • Code: 201
    Content: Created

    OR

  • Code: 201
    Content: Created with Debug Enabled

    Sample:

{
      "add_serial_to_back": true,
      "auxiliary": null,
      "back": null,
      "bar": {
      },
      "custom": null,
      "description": null,
      "format_version": null,
      "header": [
        {
          "changeMessage": "Gate changed",
          "key": "gate",
          "label": "GATE",
          "value": ""
        }
      ],
      "kind_id": 5,
      "organization_name": "Passdock Airlines",
      "pass_type_identifier": "pass.passdock.sample1",
      "primary": [
      ],
      "relevance": {
        "relevantDate": ""
      },
      "secondary": null,
      "team_identifier": "6J39RL8VD6",
      "title": "Passdock Airways",
      "visual": {
        "backgroundColor": "rgb(32,87,132)",
        "foregroundColor": "rgb(255,255,255)",
        "labelColor": " "
      }
    }

Error Response:

  • Code: 400
    Content: Bad Request

    OR

  • Code: 401
    Content: Unauthorized

Sample Call:

curl -i -d 'debug=true&errors=true&family={"title":"Passdock Airways","header":[{"key":"gate","label":"GATE","value":"","changeMessage":"Gate changed"}],"primary":[],"custom":null,"visual":{"backgroundColor":"rgb(32,87,132)","foregroundColor":"rgb(255,255,255)","labelColor":" "},"relevance":{"relevantDate":""},"bar":{}, "organization_name":"Passdock Airlines","kind_id":5}&certificate={"data":"THE_CERTIFICATE_ATTRIBUTE_BAG"}&icon={"filename":"test.png","data":"THE_BASE_64_ENCODED_IMAGE"}' https://api.passdock.com/api/v1/templates?api_token=11edb4f913d11cfa7ce8b61546948a3f