title: How to add a new API endpoint route in strapi?
body: <p>I'm new to strapi and backend in general.</p>
  
  <p>I have created a content type called post and it is accessible by this route <code>/posts/:id</code> by default. However I also want this post to be accessible in this route <code>/posts/:slug</code> .
  I tried adding a new route in the <code>routes.json</code> file but when I visit the route, it returns a 404 error.</p>
  
  <p>How do I achieve this?</p>
  
  <p>EDIT:</p>
  
  <p>My <code>routes.json</code> file looks like this:</p>
  
  <pre><code>{
    "routes": [{
        "method": "GET",
        "path": "/posts",
        "handler": "Post.find",
        "config": {
          "policies": []
        }
      },
      {
        "method": "GET",
        "path": "/posts/count",
        "handler": "Post.count",
        "config": {
          "policies": []
        }
      },
      {
        "method": "GET",
        "path": "/posts/:id",
        "handler": "Post.findOne",
        "config": {
          "policies": []
        }
      },
      {
        "method": "GET",
        "path": "/posts/:slug",
        "handler": "Post.findOne",
        "config": {
          "policies": []
        }
      },
      {
        "method": "POST",
        "path": "/posts",
        "handler": "Post.create",
        "config": {
          "policies": []
        }
      },
      {
        "method": "PUT",
        "path": "/posts/:id",
        "handler": "Post.update",
        "config": {
          "policies": []
        }
      },
      {
        "method": "DELETE",
        "path": "/posts/:id",
        "handler": "Post.delete",
        "config": {
          "policies": []
        }
      }
    ]
  }
  </code></pre>