{"id":23380594,"url":"https://github.com/agility/agility-content-management-js-sdk","last_synced_at":"2025-07-08T08:03:19.029Z","repository":{"id":42554068,"uuid":"258220735","full_name":"agility/agility-content-management-js-sdk","owner":"agility","description":"JavaScript library for the Agility CMS Content Management API.","archived":false,"fork":false,"pushed_at":"2025-04-22T13:17:21.000Z","size":2243,"stargazers_count":5,"open_issues_count":15,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-22T14:27:54.329Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/agility.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-04-23T13:49:39.000Z","updated_at":"2025-04-22T13:17:24.000Z","dependencies_parsed_at":"2024-06-21T05:47:06.950Z","dependency_job_id":"e45db397-bd5a-438c-928d-f3d6c6a5e308","html_url":"https://github.com/agility/agility-content-management-js-sdk","commit_stats":{"total_commits":53,"total_committers":8,"mean_commits":6.625,"dds":0.6226415094339622,"last_synced_commit":"fdcc1d028dfe6c426d175ee4d0a456d9973bbb56"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/agility/agility-content-management-js-sdk","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agility%2Fagility-content-management-js-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agility%2Fagility-content-management-js-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agility%2Fagility-content-management-js-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agility%2Fagility-content-management-js-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/agility","download_url":"https://codeload.github.com/agility/agility-content-management-js-sdk/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agility%2Fagility-content-management-js-sdk/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264229175,"owners_count":23576233,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-21T20:16:54.776Z","updated_at":"2025-07-08T08:03:19.017Z","avatar_url":"https://github.com/agility.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"🚨 Deprecation Notice\n\nThis package has been deprecated and is no longer maintained.\n\nPlease use our new SDK instead:\n👉 [`@agility/management-sdk`](https://www.npmjs.com/package/@agility/management-sdk)\n\n\nThe @agility/content-management package has been replaced with a more powerful and fully supported SDK. Future updates, bug fixes, and enhancements will only be made to @agility/management-sdk.\n\nIf you are currently using this package, we strongly recommend migrating as soon as possible.\n---\n\n# Agility Content Management JS SDK\n\nThis is the official JavaScript library for inserting, updating, managing and importing content, pages and media in your [Agility CMS](https://agilitycms.com) instance.\n\nDon't have an Agility CMS instance? Sign up for [Free (forever)](https://account.agilitycms.com/sign-up?product=agility-free) today!\n\n## Features\n\nProgrammatically manage content via JavaScript API client\n\n| Agility Instance Management | Content Management | Media Management | URL Redirections          | WebHooks       |\n| --------------------------- | ------------------ | ---------------- | ------------------------- | -------------- |\n| Get API                     | Approve Content    | Get Media        | Delete URL Redirection    | Delete WebHook |\n|                             | Decline Content    | Upload Media     | Save URL Redirection      | Save WebHook   |\n|                             | Delete Content     |                  | Save URL Redirection Test |                |\n|                             | Publish Content    |                  |                           |                |\n|                             | Request Approval   |                  |                           |                |\n|                             | Save Content Item  |                  |                           |                |\n|                             | Unpublish Content  |                  |                           |                |\n|                             | Get Content Item   |                  |                           |                |\n\n## Getting Started\n\n### Installation\n\nInstall it using **npm** (recommended):\n\n```\nnpm install @agility/content-management\n```\n\n## Making a Request\n\n### Create an instance of API client for Agility Content Management REST API\n\n#### Get API\n\n```javascript\nimport agilityMgmt from \"@agility/content-management\";\n\nconst mgmtApi = agilityMgmt.getApi({\n  location: \"USA\",\n  websiteName: \"MyWebsiteName\",\n  securityKey: \"xyz123\",\n});\n```\n\n### Content Management\n\n#### Get Content Item\n\n```javascript\n//Set the contentID and language code of content you want to approve\nlet contentID = contentIDToWorkOn;\nlet languageCode = \"en-us\";\n\napi\n  .getContentItem({\n    contentID,\n    languageCode,\n  })\n  .then(function (item) {\n    //the item is your content item\n  })\n  .catch(function (error) {\n    //handle error\n  });\n```\n\n#### Approve Content\n\n```javascript\n//Set the contentID and language code of content you want to approve\nlet contentID = contentIDToWorkOn;\nlet languageCode = \"en-us\";\n\napi\n  .approveContent({\n    contentID,\n    languageCode,\n  })\n  .then(function (contentID) {\n    //check contentID is greater \u003e 0 for success\n  })\n  .catch(function (error) {\n    //handle error\n  });\n```\n\n#### Decline Content\n\n```javascript\n//Set the contentID and language code of content you want to decline\nlet contentID = contentIDToWorkOn;\nlet languageCode = \"en-us\";\n\napi\n  .declineContent({\n    contentID,\n    languageCode,\n  })\n  .then(function (contentID) {\n    //check contentID is greater \u003e 0 for success\n  })\n  .catch(function (error) {\n    //handle error\n  });\n```\n\n#### Delete Content\n\n```javascript\n//Set the contentID and language code of content you want to delete\nlet contentID = contentIDToWorkOn;\nlet languageCode = \"en-us\";\n\napi\n  .deleteContent({\n    contentID,\n    languageCode,\n  })\n  .then(function (contentID) {\n    //check contentID is greater \u003e 0 for success\n  })\n  .catch(function (error) {\n    //handle error\n  });\n```\n\n#### Publish Content\n\n```javascript\n//Set the contentID and language code of content you want to publish\nlet contentID = contentIDToWorkOn;\nlet languageCode = \"en-us\";\n\napi\n  .publishContent({\n    contentID,\n    languageCode,\n  })\n  .then(function (contentID) {\n    //check contentID is greater \u003e 0 for success\n  })\n  .catch(function (error) {\n    //handle error\n  });\n```\n\n#### Request Approval\n\n```javascript\n//Set the contentID and language code of content you want to request for approval\nlet contentID = contentIDToWorkOn;\nlet languageCode = \"en-us\";\n\napi\n  .requestApproval({\n    contentID,\n    languageCode,\n  })\n  .then(function (contentID) {\n    //check contentID is greater \u003e 0 for success\n  })\n  .catch(function (error) {\n    //handle error\n  });\n```\n\n#### Save Content Item\n\n```javascript\n//Set the contentItem structure\n//Important: The fields are not camel case - make sure the field names match EXACTLY with your content definition in Agility instance\n//The example below shows how to structure your fields with simple types and nested objects\nlet contentItem = {\n  contentID: -1,\n  fields: {\n    Title: \"Test Title\",\n    Image: {\n      mediaID: 123,\n      label: \"Test Image\",\n    },\n  },\n};\n\n//Set language code and reference name of content you want to save\nlet languageCode = \"en-us\";\nlet referenceName = \"MyReferenceName\";\n\napi\n  .saveContentItem({\n    contentItem,\n    languageCode,\n    referenceName,\n  })\n  .then(function (contentID) {\n    //check contentID is greater \u003e 0 for success\n    //update contentID of saved item\n    contentIDToWorkOn = contentID;\n  })\n  .catch(function (error) {\n    //handle error\n  });\n```\n\n#### Unpublish Content\n\n```javascript\n//Set the contentID and language code of content you want to unpublish\nlet contentID = contentIDToWorkOn;\nlet languageCode = \"en-us\";\n\napi\n  .unpublishContent({\n    contentID,\n    languageCode,\n  })\n  .then(function (contentID) {\n    //check contentID is greater \u003e 0 for success\n  })\n  .catch(function (error) {\n    //handle error\n  });\n```\n\n### Media Management\n\n#### Get Media\n\n```javascript\n//Set the path to the media\n//Important: The path is the file name in Agility Media you need to access\nlet path = \"test.png\";\n\napi\n  .getMediaID({\n    path,\n  })\n  .then(function (mediaObj) {\n    //check if media is not null/empty and has valid url for success\n  })\n  .catch(function (error) {\n    //handle error\n  });\n```\n\n#### Upload Media\n\n```javascript\n//Create media stream, save blob variable and set filename\nlet blob = fs.createReadStream(\"./test/sample/logo.png\");\nlet filename = `test-${new Date()\n  .toISOString()\n  .replace(/\\./g, \"\")\n  .replace(/:/g, \"\")}.png`;\n\napi\n  .uploadMedia({\n    fileName: filename,\n    fileContent: blob,\n  })\n  .then(function (mediaObj) {\n    //check if media is not null/empty and has valid url for success\n  })\n  .catch(function (error) {\n    //handle error\n  });\n```\n\n### URL Redirections\n\n#### Delete URL Redirection\n\n```javascript\napi\n  .deleteUrlRedirection({\n    urlRedirectionID: urlRedirectionIDToDelete,\n  })\n  .then(function () {\n    console.log(\"deleted\");\n  })\n  .catch(function (error) {\n    //handle error\n  });\n```\n\n#### Save URL Redirection\n\n```javascript\napi\n  .saveUrlRedirection({\n    originUrl: \"/from/link\",\n    destinationUrl: \"/to/link\",\n  })\n  .then(function (urlRedirectionID) {\n    console.log(\"saved \", urlRedirectionID);\n  })\n  .catch(function (error) {\n    //handle error\n  });\n```\n\n#### Save URL Redirection Test\n\n```javascript\napi\n  .saveUrlRedirectionTest({\n    urlRedirectionID: urlRedirectionIDtoUpdate,\n    passed: true,\n    testResult: \"- 301 to /dest-url\",\n  })\n  .then(function () {\n    console.log(\"updated test\");\n  })\n  .catch(function (error) {\n    //handle error\n  });\n```\n\n### WebHooks\n\n#### Delete WebHook\n\n```javascript\n//Specify the URL of the webhook to delete\nconst urlToWorkOn = `http://test.url.com`;\napi\n  .deleteWebHook({ url: urlToWorkOn })\n  .then(function () {\n    console.log(\"deleted\");\n  })\n  .catch(function (error) {\n    //handle error\n  });\n```\n\n#### Save WebHook\n\n```javascript\n//Create a new webhook and set what events to receive\nconst name = `Test WebHook`;\nconst urlToWorkOn = `http://test.url.com`;\n\napi\n  .saveWebHook({\n    url: urlToWorkOn,\n    name,\n    publishEvents: false,\n    saveEvents: true,\n    workflowEvents: false,\n  })\n  .then(function () {\n    //handle success\n  })\n  .catch(function (error) {\n    //handle error\n  });\n```\n\n## Documentation\n\nFull documentation for this SDK can be found in our [Agility Management JS SDK Reference Doc](https://agilitydocs.netlify.app/agility-content-management-js-sdk)\n\nFor docs \u0026 help around Agility CMS, please see [Agility CMS Documentation](https://help.agilitycms.com/hc/en-us)\n\n### Tutorials\n\n[Calling the Content Management API using the JavaScript SDK](https://help.agilitycms.com/hc/en-us/articles/360042919711)\n\n## Contributing\n\nIf you would like to contribute to this SDK, you can fork the repository and submit a pull request. We'd love to include your updates.\n\n### Running the Tests\n\nAn essential part of contributing to this SDK is adding and running unit tests to ensure the stability of the project.\n\n```\n\u003e npm run test\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fagility%2Fagility-content-management-js-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fagility%2Fagility-content-management-js-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fagility%2Fagility-content-management-js-sdk/lists"}