# Adding Resources

Adding a new resource is done by submitting a payload with the `POST` HTTP method. The route will be defined as `{your-bakery-slug}.{resource}.add`&#x20;

Within your resource you can define two classes which will work with your model. The first is a `generator` class, which will be responsible for the instantiation of your new model.

The second is a `modifier` which will make changes to your model immediately before save.

The `fields` configuration allows you to specify either which fields you want to populate, or which fields you do not want to populate from the request, using the `populate` or `exclude` keys as appropriate.

As always you can fire off your own events, which will stack on top of the globally specified events.

You may also specify a validator class, which implements the `ProvidesBakeryValidationRules` interface, to retrieve validation rules.

```
/* Create new model */
      'post' => [

        /* Security configurations */
        'security' => [
          'policy' => 'create',
          'gate' => 'admin'
        ]

        /* Generators are responsible for instantiation of a fresh model */
        'generator' => Generator::class,

        /* Modifier is used immediate before save */
        'modifier' => Modifier::class,

        /* Resource to return - if we want to return a resource/transformed instance of this model after creation */
        'resource' => Resource::class,

        /* What fields shall we either explicitly populate or explicitly exclude */
        'fields' => [
          'populate' => ['name', 'email'],
          'exclude' => ['password']
        ],

        /* Fire these events */
        'events' => [
          EventOne::class
        ],

        /* Validation */
        'validator' => ProvidesValidation::class,
        
      ],
```

Security can be defined as per the [security specification](https://bakery.jtclabs.com/security).
