Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

add
URL/api/v1/api.php?target=resource&action=add
DescriptionAdd a resource.
Returns

Examples:

/api/v1/api.php?target=resource&action=add&meta[name]=apitest&meta[type]=entry&meta[section]=firewall&fields[network-fqdn][]=www.example.com

SUCCESSFUL: {"success":1,"message":"Resource added","data":{"id":1077,"name":"apitest","slug":"apitest","type":"entry","parent_id":1,"category_id":"NULL","attr":{"_section":"70","network-fqdn":"www.example.com"},"section":{"id":"70","name":"Firewall","slug":"firewall","type":"section","parent_id":"1","category_id":null,"attr":{}}}}

/api/v1/api.php?target=resource&action=add&meta[name]=apitest&meta[type]=entry&fields[network-fqdn][]=www.example.com

ERROR:{"success":0,"message":"Entries must be assigned to a section"}

Required Parameters
NameTypeNotes/Example
meta[name]STRINGName of the resource
meta[type]STRINGType of resource (entry, section, field, ect)
Optional Parameters
NameTypeNotes/Example
meta[parent_id]INTEGERID of the parent resource
meta[category_id]INTEGERID of the category

Required Parameters

(meta[type] = entry)


One of the following:

NameTypeNotes/Example
meta[section_id]INTEGERID of the section that the entry will be assigned to
meta[section]STRINGSlug of the section that the entry will be assigned to

Optional Parameters

(meta[type] = entry)

NameTypeNotes/Example
fields[]ARRAY

Entry field values (for fields that have already been assigned to the section) can be populated when the entry is created.

The format is field[field-slug][field-instance]. If the field instance is left blank, it will simply be the next value in the instance array. For example:

fields[network-fqdn][]=example.com&fields[network-fqdn][]=test.com

translates to

fields = array(
     network-fqdn =﹥ array(
          0 =﹥ 'example.com',
          1 =﹥ 'test.com',
     )
)

A field can be added to a section multiple times. The field instance is used to keep track of which field occurrence we are referring. In this example, the network-fqdn field had been added twice to the section so we were able to store two values for it.

meta[custom_id]STRINGA custom ID for the entry. In the past this has been called the Resource Holder ID or Customer ID. Most recently it was implemented as a text field with the slug "6c-resourceholder-id." Now it is a fundamental part the entry type resources.

Required Parameters

(meta[type] = field)

NameTypeNotes/Example
meta[field_type]STRING

Type of field

  • text
  • textarea
  • radios
  • checkboxes
  • choicebox

Optional Parameters

(meta[type] = field)

NameTypeNotes/Example
meta[help_block]STRINGFields can have a line of text under them with instructions
meta[options]ARRAY

Fields of type radios, checkboxes, or choicebox can have multiple options. This could be multiple radio buttons or a choicebox (dropdown) with several options. For example:

meta[type]=field&meta[name]=Colors&meta[field_type]=choicebox&meta[options][]=Blue&meta[options][]=Green

Will create a choicebox with dropdown options of Blue and Green.

...