|
| 1 | + |
| 2 | +# ServiceNow Catalog Builder API |
| 3 | +**Automate Catalog Item Creation with a Single REST Call** |
| 4 | + |
| 5 | +--- |
| 6 | + |
| 7 | +## Overview |
| 8 | + |
| 9 | +The **ServiceNow Catalog Builder API** is a custom **Scripted REST API** that dynamically creates Service Catalog Items in your instance — including variables and choices — from a simple JSON payload. |
| 10 | + |
| 11 | +This API eliminates the repetitive manual work of configuring Catalog Items one by one, and makes it possible to **automate catalog creation programmatically** or **integrate it with CI/CD pipelines, GitHub workflows, or external systems**. |
| 12 | + |
| 13 | +--- |
| 14 | + |
| 15 | +## Key Features |
| 16 | + |
| 17 | +Automatically create **Catalog Items** in `sc_cat_item` |
| 18 | +Dynamically generate **Variables** and **Choices** |
| 19 | +Supports **category mapping** and **item ownership** |
| 20 | +Extensible design for **flows, icons, and attachments** |
| 21 | +Developer-friendly — fully JSON-driven |
| 22 | + |
| 23 | +--- |
| 24 | + |
| 25 | +## Use Case |
| 26 | + |
| 27 | +This API is perfect for: |
| 28 | +- **Admin Automation:** Auto-build standard catalog forms during environment setup. |
| 29 | +- **RPA / CI Pipelines:** Integrate with DevOps or GitHub Actions to deploy catalog definitions. |
| 30 | +- **Dynamic Service Portals:** Allow external apps or portals to create items on demand. |
| 31 | + |
| 32 | +Example: |
| 33 | +A company wants to auto-create 10 new service catalog items from a GitHub configuration file. |
| 34 | +Using this API, they simply call one REST endpoint for each definition — no manual clicks needed. |
| 35 | + |
| 36 | +--- |
| 37 | + |
| 38 | +## Scripted REST API Details |
| 39 | + |
| 40 | +| Property | Value | |
| 41 | +|-----------|--------| |
| 42 | +| **Name** | Catalog Builder API | |
| 43 | +| **API ID** | `x_demo.catalog_creator` | |
| 44 | +| **Resource Path** | `/create` | |
| 45 | +| **Method** | POST | |
| 46 | +| **Authentication** | Basic Auth / OAuth | |
| 47 | +| **Tables Used** | `sc_cat_item`, `item_option_new`, `question_choice` | |
| 48 | + |
| 49 | +--- |
| 50 | + |
| 51 | +## Logic Flow |
| 52 | + |
| 53 | +1. **Receive JSON input** with item name, category, and variables. |
| 54 | +2. **Create a new record** in `sc_cat_item`. |
| 55 | +3. **Loop through variables** and create them in `item_option_new`. |
| 56 | +4. If the variable type is `select_box`, create **choices** automatically. |
| 57 | +5. Return a JSON response with the new item’s `sys_id` and success message. |
| 58 | + |
| 59 | +--- |
| 60 | + |
| 61 | +## Example Input (POST Body) |
| 62 | + |
| 63 | +```json |
| 64 | +{ |
| 65 | + "name": "Request New Laptop", |
| 66 | + "category": "Hardware", |
| 67 | + "short_description": "Laptop provisioning request form", |
| 68 | + "description": "Allows employees to request a new laptop with model and RAM options.", |
| 69 | + "owner": "admin", |
| 70 | + "variables": [ |
| 71 | + { |
| 72 | + "name": "Laptop Model", |
| 73 | + "type": "select_box", |
| 74 | + "choices": "Dell,HP,Lenovo" |
| 75 | + }, |
| 76 | + { |
| 77 | + "name": "RAM Size", |
| 78 | + "type": "select_box", |
| 79 | + "choices": "8GB,16GB,32GB" |
| 80 | + }, |
| 81 | + { |
| 82 | + "name": "Business Justification", |
| 83 | + "type": "multi_line_text" |
| 84 | + } |
| 85 | + ] |
| 86 | +} |
| 87 | + |
| 88 | + |
| 89 | +## Example Output: |
| 90 | +{ |
| 91 | + "catalog_sys_id": "b2f6329cdb6d0010355b5fb4ca9619e2", |
| 92 | + "message": "Catalog item created successfully!" |
| 93 | +} |
| 94 | +After the API call: |
| 95 | +A new Catalog Item appears under Maintain Items. |
| 96 | +The item contains: |
| 97 | +Short Description: Laptop provisioning form |
| 98 | +Variables: Laptop Model, RAM Size, Business Justification |
| 99 | +Choices: Auto-populated for select boxes |
| 100 | +The item is active and ready to use in the catalog. |
0 commit comments