title: Is there a pattern for defining a "template" resource in a RESTful API?
body: <p>Let's say I am building a web app (using React, in case that matters) where someone can create a new Widget. Some Widget properties have default values defined in data models in the API. These default values need to be displayed in the UI form for creating the new Widget.</p>
  <p>I'd like to avoid duplicating these defaults in the app versus the API data models. Here is a sample data model as defined in the API:</p>
  <pre><code>Widget
    _id
    name
    messageTextColor (default #999999)
    bodyBackgroundColor (default #FFFFFF)
    someBooleanValue (default true)
    someOtherBooleanValue (default false)
    ... and so on
  </code></pre>
  <p>There are over a dozen settings, and many have default values.</p>
  <p>I could duplicate these defaults in my UI app:</p>
  <pre><code>class EditWidgetPage extends React.Component {
    constructor(props) {
      super(props);
  
      this.state = {
        name: '',
        messageTextColor: '#999999',
        bodyBackgroundColor: '#FFFFFF',
        someBooleanValue: true,
        someOtherBooleanValue: false,
        ... etc
      };
    }
  }
  </code></pre>
  <p>I could also define a resource in my API, <code>GET /widgets/new</code>, which returns a &quot;template&quot; widget:</p>
  <pre><code>{
    name: '',
    messageTextColor: '#999999',
    bodyBackgroundColor: '#FFFFFF',
    someBooleanValue: true,
    someOtherBooleanValue: false,
    ... etc
  }
  </code></pre>
  <p>I'm wondering if anyone can point me to information online (e.g., blog articles) related to a common pattern whereby a &quot;template&quot; resource is accessible in a RESTful API -- or even an alternative approach not listed here.</p>