Answers.Body: <p><strong>Tl;dr:</strong> Mutations in GraphQL seems to be the way to go - <del>but GraphQL in Craft doesn't yet support mutations on Commerce elements. As for now, you have to create a Craft CMS Plugin.</del> <a href="https://github.com/craftcms/commerce/issues/1092" rel="nofollow noreferrer">Follow the progress of mutations support on GitHub</a></p>
  <p><strong>Alternative 1 (sort of)</strong></p>
  <p>According to <a href="https://craftcms.stackexchange.com/a/27621/9667">#9667</a> - the 3rd party <a href="https://plugins.craftcms.com/craftql" rel="nofollow noreferrer">CraftQL-plugin</a> lets you do CRUD on everything* via <a href="https://graphql.org/learn/queries/#mutations" rel="nofollow noreferrer">Mutations</a> (GraphQL way of altering data) - so that's an alternative while we wait to the native GraphQL functionality to support Mutations (see <a href="https://github.com/craftcms/cms/issues/4835" rel="nofollow noreferrer">https://github.com/craftcms/cms/issues/4835</a> for status on that one. It's a part of the 4.0 milestone)</p>
  <p>Also, Pixel &amp; Tonic has <a href="https://github.com/craftcms/cms/issues/4835" rel="nofollow noreferrer">added support for Mutations to the 4.0 milestone</a> for Craft CMS on the built in GraphQL plugin. So it's coming.</p>
  <p>* Well, not <em>everything</em>. CraftQL supports the following entities: entries, sites, draft, assets, globals, tags and users. The documentation contains a section about <a href="https://github.com/markhuot/craftql#third-party-field-support" rel="nofollow noreferrer">third-party field support</a> that probably lets you implement support for mutating Craft Commerce-fields and other 3rd party fields.</p>
  <p>I've added a Feature Request on Craft Commerce <a href="https://github.com/craftcms/commerce/issues/1092" rel="nofollow noreferrer">regarding GraphQL and mutations</a>. Let's see what they answer.</p>
  <p><strong>Alternative 2 (only real alternative in 2019)</strong></p>
  <p>Also, if you can't wait for mutations in Craft Commerce, you can create your own Craft Plugin. Have a look at my question &quot;<a href="https://craftcms.stackexchange.com/questions/32978/how-to-accept-incoming-webhooks">How to accept incoming Webhooks</a>&quot;, which helps you along with creating a plugin that can do things like creating and modifying products in Craft.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-10-14T10:09:14.473Z
Answers.LastActivityDate: 2021-02-02T09:56:04.323Z
Answers.LastEditDate: 2021-02-02T09:56:04.323Z
Answers.UserDisplayName: nitech
Answers.Body: <p>It depends on the capabilities of the 3rd party. Assuming they have the ability to trigger an http request to your Craft site, you would typically point that request to a custom controller action to trigger whatever updates you need based on the http post data. </p>
  
  <p>You'll probably need to build some kind of authentication, such as checking a secret code sent by the third-party, or something more robust such as JSON Web Tokens.</p>
  
  <p>The Craft 3 docs around controllers are pretty lacking at the time of writing IMO, but the V2 docs can get you most of the way there: <a href="https://docs.craftcms.com/v2/plugins/controllers.html" rel="nofollow noreferrer">https://docs.craftcms.com/v2/plugins/controllers.html</a></p>
  
  <p><a href="https://docs.craftcms.com/v3/extend/module-guide.html" rel="nofollow noreferrer">https://docs.craftcms.com/v3/extend/module-guide.html</a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-10-14T08:06:28.153Z
Answers.Text: So far Craft CMS has surprised me time after time with its functionality and simplicity - but now I became a little disappointed. So what you are saying is that there is no first party API with authentication in Craft? (it would make sense to re-use the existing authentication module)
Answers.UserDisplayName: nitech
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-10-11T11:16:30.913Z
Answers.LastActivityDate: 2019-10-11T11:16:30.913Z
Answers.UserDisplayName: James Smith
Body: <p>I want to update certain fields of a product (or entry) from a 3rd party.</p>
  
  <p>I see some talk about plugins and some refer to <a href="https://dotall.com/sessions/how-to-create-a-full-rest-api-with-craft-3" rel="nofollow noreferrer">this .all talk about Creating a RESTful API with Craft 3</a>.</p>
  
  <p>I found the <a href="https://github.com/craftcms/element-api" rel="nofollow noreferrer">Craft CMS Element API</a>, but it seems to be a way to create a read-only API. </p>
  
  <p>How can I update a product's fields from a 3rd party?</p>
  
Tags: <plugins><api>
Title: How to update (or CRUD) products (or entries) via API?
ThreadText: # How to update (or CRUD) products (or entries) via API?
  
  (Asked by: username_0 on 2019-10-04)
  
  I want to update certain fields of a product (or entry) from a 3rd party.
  
  I see some talk about plugins and some refer to [this .all talk about Creating a RESTful API with Craft 3](https://dotall.com/sessions/how-to-create-a-full-rest-api-with-craft-3).
  
  I found the [Craft CMS Element API](https://github.com/craftcms/element-api), but it seems to be a way to create a read-only API.
  
  How can I update a product's fields from a 3rd party?
  
  **Tags:** plugins, api
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_0 on 2019-10-14. Score: 2 | Accepted answer
  
  **Tl;dr:** Mutations in GraphQL seems to be the way to go - ~~but GraphQL in Craft doesn't yet support mutations on Commerce elements. As for now, you have to create a Craft CMS Plugin.~~ [Follow the progress of mutations support on GitHub](https://github.com/craftcms/commerce/issues/1092)
  
  **Alternative 1 (sort of)**
  
  According to [#9667](https://craftcms.stackexchange.com/a/27621/9667) - the 3rd party [CraftQL-plugin](https://plugins.craftcms.com/craftql) lets you do CRUD on everything\* via [Mutations](https://graphql.org/learn/queries/#mutations) (GraphQL way of altering data) - so that's an alternative while we wait to the native GraphQL functionality to support Mutations (see <https://github.com/craftcms/cms/issues/4835> for status on that one. It's a part of the 4.0 milestone)
  
  Also, Pixel & Tonic has [added support for Mutations to the 4.0 milestone](https://github.com/craftcms/cms/issues/4835) for Craft CMS on the built in GraphQL plugin. So it's coming.
  
  \* Well, not *everything*. CraftQL supports the following entities: entries, sites, draft, assets, globals, tags and users. The documentation contains a section about [third-party field support](https://github.com/markhuot/craftql#third-party-field-support) that probably lets you implement support for mutating Craft Commerce-fields and other 3rd party fields.
  
  I've added a Feature Request on Craft Commerce [regarding GraphQL and mutations](https://github.com/craftcms/commerce/issues/1092). Let's see what they answer.
  
  **Alternative 2 (only real alternative in 2019)**
  
  Also, if you can't wait for mutations in Craft Commerce, you can create your own Craft Plugin. Have a look at my question "[How to accept incoming Webhooks](https://craftcms.stackexchange.com/questions/32978/how-to-accept-incoming-webhooks)", which helps you along with creating a plugin that can do things like creating and modifying products in Craft.
  
  
  ---
  
  ### Answer by username_1 on 2019-10-11. Score: 1
  
  It depends on the capabilities of the 3rd party. Assuming they have the ability to trigger an http request to your Craft site, you would typically point that request to a custom controller action to trigger whatever updates you need based on the http post data.
  
  You'll probably need to build some kind of authentication, such as checking a secret code sent by the third-party, or something more robust such as JSON Web Tokens.
  
  The Craft 3 docs around controllers are pretty lacking at the time of writing IMO, but the V2 docs can get you most of the way there: <https://docs.craftcms.com/v2/plugins/controllers.html>
  
  <https://docs.craftcms.com/v3/extend/module-guide.html>
  
  > **Comments:**
  > **username_0**: So far Craft CMS has surprised me time after time with its functionality and simplicity - but now I became a little disappointed. So what you are saying is that there is no first party API with authentication in Craft? (it would make sense to re-use the existing authentication module)  
  
  ---
  
  