There are two answers:
If you have submitted a form, just return 200 - OK
with HTML explaining why the object was not created.
If you have an API you should use the following
200 OK
- When the request was OK and returned the proper data.
201 CREATED
- The call was successful and the new object created.
400 BAD REQUEST
- Invalid request URI
- Invalid HTTP Header
- Receiving an unsupported, nonstandard parameter
- Receiving an invalid HTTP Message Body
401 UNAUTHORIZED
- Authorization problems. E.g. wrong API key, etc.
403 FORBIDDEN
- Properly authorized, but not allowed.
404 NOT FOUND
- The resource does not exist (e.g. on Read or Update)
405 METHOD NOT ALLOWED
- Use in situations that a given REST method is not allowed. E.g. a POST on a single resource, or a DELETE on the entire collection of resources.
409 CONFLICT
- When an update fails, send "Conflict" to allow the client side to resolve the conflict themselves and retry.
500 INTERNAL SERVER ERROR
- Internal error. This is the default code that is used for all unrecognized errors.
501 NOT IMPLEMENTED
- Use for expected, but not yet implemented features.